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

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Core/Utilities/Includes/Utilities.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //     File: $Source: /home/cvs/ISG-Repository/IDEA-DEV/Core/Utilities/Includes/Utilities.hh,v $
00003 //      Tag: $Name: DR_01_11_06 $
00004 //      CVS: $Id: Utilities.hh,v 1.18 2006/01/06 01:18:42 chucko Exp $
00005 //     Info: $CVSROOT/IDEA-DEV/COPYRIGHT
00006 
00007 #ifndef _UTILITY_HEADER_FILE_DEFINITION_HEADER__
00008 #define _UTILITY_HEADER_FILE_DEFINITION_HEADER__
00009 
00010 #include "StatusTypes.hh"
00011 
00012 #include <sstream>
00013 #include <iostream>
00014 #include <list>
00015 #include <set>
00016 #include <map>
00017 #include <vector>
00018 
00023 namespace IDEA
00024 {
00033   typedef std::list< std::string > StringList;
00037   typedef std::set< std::string > StringSet;
00041   typedef std::vector< std::string > StringVector;
00045   typedef std::list< int > IntList;
00049   typedef std::vector< int > IntVector;
00053   typedef std::set< int > IntSet;
00057   typedef std::list< double > DoubleList;
00061   extern std::string UNKNOWN;
00065   std::ostream& operator<<( std::ostream& os, const IntSet& is );
00069   std::ostream& operator<<( std::ostream& os, const StringSet& ss );
00073   std::ostream& operator<<( std::ostream& os, const StringList& ss );
00077   std::ostream& operator<<( std::ostream& os, const StringVector& ss );
00086   void* loadSharedLibrary( const std::string& fileName );
00098   template<class Type> std::string toString( Type& t )
00099   {
00100     std::ostringstream ss;
00101 
00102     if( !(ss << t ) )
00103       {
00104         std::cerr << "Error: can not parse value '" << t << "' to string." << std::endl;
00105         
00106         abort();
00107       }
00108 
00109     return ss.str();
00110   }
00111 
00119   template <> std::string toString( double& t );
00123   template <> std::string toString( bool& t );
00128   template<> std::string toString( StatusType& t );
00133   template<class Type> Type toValue( const std::string& st )
00134   {
00135     std::istringstream sst( st );
00136 
00137     Type value;
00138     
00139     if( !( sst >> value ) )
00140       {
00141         std::cerr<< "Can not parse string '" << st << "' to requested type." << std::endl;
00142         
00143         abort();
00144       }
00145     
00146     return value;
00147   }
00151   template<> bool toValue( const std::string& st );
00155   bool toBool( const std::string& st );
00176   bool readPlannerArg(std::string& arglist, std::string& arg);  
00181   void removeTrailingBlanks( std::string& text);
00186   void removeLeadingBlanks( std::string& text);
00191   bool findString(const std::string& text, const char *pattern);
00195   bool findLeadingString(const std::string& text, const char *pattern);
00201   bool doesFileExist( const std::string& name );
00205   char* copyString(const char* str); 
00206   /*
00207     }@
00208   */
00209 } //namespace IDEA
00210 
00211 
00212 #endif // _UTILITY_HEADER_FILE_DEFINITION_HEADER__

Contact information
© IDEA
Generated on Fri Feb 3 17:09:41 2006 for IDEA.