Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dconfig/expand.I

Go to the documentation of this file.
00001 // Filename: expand.I
00002 // Created by:  cary (20Mar00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 INLINE bool Base_Expander::isEnv(ConfigString S) {
00020   return (getenv(S.c_str()) != (TYPENAME ConfigString::value_type *)0L);
00021 }
00022 
00023 INLINE ConfigString Base_Expander::Env(ConfigString S) {
00024   return isEnv(S)?getenv(S.c_str()):"";
00025 }
00026 
00027 INLINE bool Base_Expander::isUser(ConfigString S) {
00028    if (S.find_first_of(VChars) == 0) {
00029       std::auto_ptr<struct passwd> pw(getpwnam(S.c_str()));
00030       return (pw.get() != (struct passwd *)0L);
00031    } else
00032       return false;
00033 }
00034 
00035 INLINE ConfigString Base_Expander::GetMyDir() {
00036    std::auto_ptr<struct passwd> pw(getpwuid(geteuid()));
00037    return pw->pw_dir;
00038 }
00039 
00040 INLINE ConfigString Base_Expander::GetUserDir(ConfigString S) {
00041    std::auto_ptr<struct passwd> pw(getpwnam(S.c_str()));
00042    return ((pw.get() != (struct passwd *)0L)?pw->pw_dir:"");
00043 }
00044 
00045 INLINE ConfigString Base_Expander::operator()(void) {
00046   return _result;
00047 }
00048 
00049 INLINE ConfigString Base_Expander::operator()(ConfigString S) {
00050   _result = Base_Expander::Expand(S);
00051   return _result;
00052 }
00053 
00054 INLINE Base_Expander::operator ConfigString() {
00055   return _result;
00056 }
00057 
00058 INLINE ConfigString Expand(ConfigString S) {
00059    Base_Expander ex(S);
00060    return ex;
00061 }

Generated on Thu May 1 22:12:57 2003 for DTool by doxygen1.3