MeVisLabToolboxReference
MeVis/Foundation/Sources/DicomTree/MLDicomTree/DCMTree_Utils.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // **InsertLicense** code
00003 //-----------------------------------------------------------------------------
00005 
00010 // uses its own namespace to avoid name-mangling problems
00011 // with alias types
00012 // (toString(unsigned int) vs. toString(Tagid) for example)
00013 //-----------------------------------------------------------------------------
00014 #ifndef CLASS_DCMTREE_UTILS
00015 #define CLASS_DCMTREE_UTILS
00016 
00017 #include <string>
00018 #include <list>
00019 #include <istream>
00020 #include <ostream>
00021 
00022 #include "DCMTree_Lib.h"
00023 #include "DCMTree_Defines.h"
00024 
00044 namespace DCMTree_Utils
00045 {
00049   const std::string configInstallPath();
00050 
00054   const std::list<std::string> configLibraryPathList(const std::string &installPath);
00055 
00060   class DCMTREE_EXPORT LoadLibraryDelegate {
00061   public:
00062     virtual ~LoadLibraryDelegate() {};
00063     virtual bool loadDICOMLibraries() = 0;
00064   };
00065 
00070   bool configLoadDll( std::string dllPath);
00071 
00075   DCMTREE_EXPORT void configLoadLibraries( LoadLibraryDelegate* delegate = NULL );
00076 
00080   typedef std::list<std::string> StringList;
00081 
00086   DCMTREE_EXPORT StringList split (const std::string &tosplit,char c,bool skipempties=false);
00087 
00091   DCMTREE_EXPORT std::string toString (const DCMTree::Date &date);
00092 
00096   DCMTREE_EXPORT std::string toString (const DCMTree::Time &time);
00097 
00101   DCMTREE_EXPORT std::string toString (const DCMTree::DateTime &datetime);
00102 
00106   DCMTREE_EXPORT std::string toString (int val);
00107 
00111   DCMTREE_EXPORT std::string toString (unsigned int val);
00112 
00116   DCMTREE_EXPORT std::string toString (float val);
00117 
00121   DCMTREE_EXPORT std::string toString (double val);
00122 
00126   DCMTREE_EXPORT DCMTree::Date toDate (const std::string &str);
00127 
00131   DCMTREE_EXPORT DCMTree::Time toTime (const std::string &str);
00132 
00136   DCMTREE_EXPORT DCMTree::DateTime toDateTime (const std::string &str);
00137 
00142   DCMTREE_EXPORT std::string digitsOnly (const std::string &str,bool allowhex=false);
00143 
00148   DCMTREE_EXPORT std::string afterFractionPart (const std::string &str);
00149 
00154   DCMTREE_EXPORT std::string beforeFractionPart (const std::string &str);
00155 
00159   DCMTREE_EXPORT int hexToInt (const std::string &str);
00160 
00164   DCMTREE_EXPORT unsigned int hexToUInt (const std::string &str);
00165 
00169   DCMTREE_EXPORT int toInt (const std::string &str);
00170 
00174   DCMTREE_EXPORT unsigned int toUInt (const std::string &str);
00175 
00179   DCMTREE_EXPORT double toDouble (const std::string &str);
00180 
00184   DCMTREE_EXPORT std::string toString(const DCMTree::Vr vr);
00185 
00190   DCMTREE_EXPORT DCMTree::Vr toVr(const std::string& vrString);
00191 
00193   DCMTREE_EXPORT void toStream (std::ostream &out,const std::string &val);
00194   DCMTREE_EXPORT void toStream (std::ostream &out,const int &val);
00195   DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned int &val);
00196   DCMTREE_EXPORT void toStream (std::ostream &out,const bool &val);
00197   DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned char *ptr,unsigned int size);
00198 
00200   DCMTREE_EXPORT void fromStream (std::istream &in,std::string &val);
00201   DCMTREE_EXPORT void fromStream (std::istream &in,int &val);
00202   DCMTREE_EXPORT void fromStream (std::istream &in,unsigned int &val);
00203   DCMTREE_EXPORT void fromStream (std::istream &in,bool &val);
00204   DCMTREE_EXPORT void fromStream (std::istream &in,unsigned char *ptr,unsigned int size);
00205 
00206   typedef void (*LoggingHandler) (std::string, int);
00207 
00209   DCMTREE_EXPORT void setLoggingHandler ( LoggingHandler handler );
00211   DCMTREE_EXPORT void logMessage( std::string message, int errorCode = 0 );
00212 
00213   DCMTREE_EXPORT std::string condGetNameForTag(DCMTree::TagId tag, const std::string &defaultName);
00214 }
00215 
00216 #endif
00217 
00218