MeVisLab Toolbox Reference
DCMTree_Utils.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 // Uses its own namespace to avoid name mangling problems
14 // with alias types
15 // (toString(unsigned int) vs. toString(Tagid) for example).
16 
17 #ifndef DCM_TREE_UTILS_H
18 #define DCM_TREE_UTILS_H
19 
20 #ifdef _MSC_VER
21  #pragma warning (push)
22  #pragma warning (disable : 4350)
23 #endif
24 
25 #include <string>
26 #include <list>
27 #include <istream>
28 #include <ostream>
29 
30 #ifdef _MSC_VER
31  #pragma warning (pop)
32 #endif
33 
34 #include "DCMTree_Lib.h"
35 #include "DCMTree_Defines.h"
36 
44 namespace DCMTree_Utils
45 {
49  const std::string configInstallPath();
50 
54  const std::list<std::string> configLibraryPathList(const std::string &installPath);
55 
61  public:
62  virtual ~LoadLibraryDelegate() {};
63  virtual bool loadDICOMLibraries() = 0;
64  };
65 
70  bool configLoadDll( std::string dllPath);
71 
76 
80  typedef std::list<std::string> StringList;
81 
86  DCMTREE_EXPORT StringList split (const std::string &tosplit,char c,bool skipempties=false);
87 
91  DCMTREE_EXPORT std::string toString (const DCMTree::Date &date);
92 
96  DCMTREE_EXPORT std::string toString (const DCMTree::Time &time);
97 
101  DCMTREE_EXPORT std::string toString (const DCMTree::DateTime &datetime);
102 
106  DCMTREE_EXPORT std::string toString (int val);
107 
111  DCMTREE_EXPORT std::string toString (unsigned int val);
112 
117  DCMTREE_EXPORT std::string toString (float val);
118 
122  DCMTREE_EXPORT std::string toString (double val);
123 
127  DCMTREE_EXPORT DCMTree::Date toDate (const std::string &str);
128 
132  DCMTREE_EXPORT DCMTree::Time toTime (const std::string &str);
133 
137  DCMTREE_EXPORT DCMTree::DateTime toDateTime (const std::string &str);
138 
143  DCMTREE_EXPORT std::string digitsOnly (const std::string &str,bool allowhex=false);
144 
149  DCMTREE_EXPORT std::string afterFractionPart (const std::string &str);
150 
155  DCMTREE_EXPORT std::string beforeFractionPart (const std::string &str);
156 
160  DCMTREE_EXPORT int hexToInt (const std::string &str);
161 
165  DCMTREE_EXPORT unsigned int hexToUInt (const std::string &str);
166 
170  DCMTREE_EXPORT int toInt (const std::string &str);
171 
175  DCMTREE_EXPORT unsigned int toUInt (const std::string &str);
176 
180  DCMTREE_EXPORT double toDouble (const std::string &str);
181 
185  DCMTREE_EXPORT std::string toString(const DCMTree::Vr vr);
186 
191  DCMTREE_EXPORT DCMTree::Vr toVr(const std::string& vrString);
192 
194  DCMTREE_EXPORT void toStream (std::ostream &out,const std::string &val);
195  DCMTREE_EXPORT void toStream (std::ostream &out,const int &val);
196  DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned int &val);
197  DCMTREE_EXPORT void toStream (std::ostream &out,const bool &val);
198  DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned char *ptr,unsigned int size);
199 
201  DCMTREE_EXPORT void fromStream (std::istream &in,std::string &val, size_t maxSize = 0);
202  DCMTREE_EXPORT void fromStream (std::istream &in,int &val);
203  DCMTREE_EXPORT void fromStream (std::istream &in,unsigned int &val);
204  DCMTREE_EXPORT void fromStream (std::istream &in,bool &val);
205  DCMTREE_EXPORT void fromStream (std::istream &in,unsigned char *ptr,unsigned int size);
206 
207  typedef void (*LoggingHandler) (std::string, int);
208 
214  DCMTREE_EXPORT void logMessage( std::string message, int errorCode = 0 );
215 
216  DCMTREE_EXPORT std::string condGetNameForTag(DCMTree::TagId tag, const std::string &defaultName);
217 }
218 
219 #endif
220 
221 
#define DCMTREE_EXPORT
Class to wrap a tag ID.
Definition: DCMTree_TagId.h:40
The delegate that is responsible for loading the specific DICOM library.
Definition: DCMTree_Utils.h:60
Dictionary class to provide DICOM meta information.
DCMTREE_EXPORT StringList split(const std::string &tosplit, char c, bool skipempties=false)
Splits the given string at each c.
DCMTREE_EXPORT DCMTree::Time toTime(const std::string &str)
Converts a string str to time.
DCMTREE_EXPORT unsigned int hexToUInt(const std::string &str)
Converts a hex-string str to unsigned int.
DCMTREE_EXPORT int hexToInt(const std::string &str)
Converts a hex-string str to int.
DCMTREE_EXPORT std::string digitsOnly(const std::string &str, bool allowhex=false)
Removes all non-digits from the given strings.
DCMTREE_EXPORT DCMTree::Date toDate(const std::string &str)
Converts a string str to a date.
std::list< std::string > StringList
A list of strings.
Definition: DCMTree_Utils.h:80
DCMTREE_EXPORT void logMessage(std::string message, int errorCode=0)
Logs a message using the provided callback, if any.
DCMTREE_EXPORT std::string toString(const DCMTree::Date &date)
Converts a date to a string.
DCMTREE_EXPORT double toDouble(const std::string &str)
Converts a string str to double.
bool configLoadDll(std::string dllPath)
Loads a dynamic library from the specified path.
DCMTREE_EXPORT std::string beforeFractionPart(const std::string &str)
Returns the part of the string before the right-most dot.
DCMTREE_EXPORT LoggingHandler getLoggingHandler()
Returns the currently set logging callback.
void(* LoggingHandler)(std::string, int)
DCMTREE_EXPORT int toInt(const std::string &str)
Converts a string str to int.
DCMTREE_EXPORT void fromStream(std::istream &in, std::string &val, size_t maxSize=0)
Helper functions to read data out of a stream.
const std::list< std::string > configLibraryPathList(const std::string &installPath)
Returns a list of paths to search for dynamic libraries.
DCMTREE_EXPORT void configLoadLibraries(LoadLibraryDelegate *delegate=nullptr)
Loads dynamic libraries and searches in file DCMTree.cfg for their names.
DCMTREE_EXPORT DCMTree::Vr toVr(const std::string &vrString)
Converts a string str to a VR.
DCMTREE_EXPORT std::string afterFractionPart(const std::string &str)
Returns the part of the string after the right-most dot.
DCMTREE_EXPORT unsigned int toUInt(const std::string &str)
Converts a string str to unsigned int.
const std::string configInstallPath()
Returns the path where the current application is installed.
DCMTREE_EXPORT std::string condGetNameForTag(DCMTree::TagId tag, const std::string &defaultName)
DCMTREE_EXPORT void setLoggingHandler(LoggingHandler handler)
Sets a callback for logging purposes.
DCMTREE_EXPORT void toStream(std::ostream &out, const std::string &val)
Helper functions to write data into a stream.
DCMTREE_EXPORT DCMTree::DateTime toDateTime(const std::string &str)
Converts a string str to datetime.
std::pair< Date, Time > DateTime
DateTime.
Definition: DCMTree_Lib.h:195
Vr
DICOM VR.
Definition: DCMTree_Lib.h:202
Date class for DCMTree library.
Definition: DCMTree_Lib.h:175
Time class for DCMTree library.
Definition: DCMTree_Lib.h:185