00001 // Filename: expand.h 00002 // Created by: cary (26Aug98) 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 #ifndef __EXPAND_H__ 00020 #define __EXPAND_H__ 00021 00022 #include <dtoolbase.h> 00023 00024 #include "pfstream.h" 00025 #include "config_setup.h" 00026 00027 #include <pwd.h> 00028 #include <memory> 00029 #include <sys/types.h> 00030 00031 namespace Expand { 00032 00033 static const ConfigString VChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; 00034 00035 class Base_Expander { 00036 private: 00037 ConfigString _result; 00038 00039 ConfigString Strip(ConfigString S); 00040 INLINE bool isEnv(ConfigString S); 00041 INLINE ConfigString Env(ConfigString S); 00042 istream& CopyStreamToString(istream& is, ConfigString& S); 00043 INLINE bool isUser(ConfigString S); 00044 INLINE ConfigString GetMyDir(void); 00045 INLINE ConfigString GetUserDir(ConfigString S); 00046 ConfigString Expand(ConfigString S); 00047 Base_Expander() {} 00048 public: 00049 Base_Expander(ConfigString S) : _result(Base_Expander::Expand(S)) {} 00050 Base_Expander(const Base_Expander& c) : _result(c._result) {} 00051 ~Base_Expander() {} 00052 INLINE ConfigString operator()(void); 00053 INLINE ConfigString operator()(ConfigString); 00054 INLINE operator ConfigString(); 00055 }; 00056 00057 typedef Base_Expander Expander; 00058 00059 INLINE ConfigString Expand(ConfigString S); 00060 00061 #include "expand.I" 00062 00063 } // Close namespace Expand 00064 00065 #endif /* __EXPAND_H__ */