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 
56 namespace DCMTree_Utils
57 {
61  const std::string configInstallPath();
62 
66  const std::list<std::string> configLibraryPathList(const std::string &installPath);
67 
73  public:
74  virtual ~LoadLibraryDelegate() {};
75  virtual bool loadDICOMLibraries() = 0;
76  };
77 
82  bool configLoadDll( std::string dllPath);
83 
88 
92  typedef std::list<std::string> StringList;
93 
98  DCMTREE_EXPORT StringList split (const std::string &tosplit,char c,bool skipempties=false);
99 
103  DCMTREE_EXPORT std::string toString (const DCMTree::Date &date);
104 
108  DCMTREE_EXPORT std::string toString (const DCMTree::Time &time);
109 
113  DCMTREE_EXPORT std::string toString (const DCMTree::DateTime &datetime);
114 
118  DCMTREE_EXPORT std::string toString (int val);
119 
123  DCMTREE_EXPORT std::string toString (unsigned int val);
124 
128  DCMTREE_EXPORT std::string toString (float val);
129 
133  DCMTREE_EXPORT std::string toString (double val);
134 
138  DCMTREE_EXPORT DCMTree::Date toDate (const std::string &str);
139 
143  DCMTREE_EXPORT DCMTree::Time toTime (const std::string &str);
144 
148  DCMTREE_EXPORT DCMTree::DateTime toDateTime (const std::string &str);
149 
154  DCMTREE_EXPORT std::string digitsOnly (const std::string &str,bool allowhex=false);
155 
160  DCMTREE_EXPORT std::string afterFractionPart (const std::string &str);
161 
166  DCMTREE_EXPORT std::string beforeFractionPart (const std::string &str);
167 
171  DCMTREE_EXPORT int hexToInt (const std::string &str);
172 
176  DCMTREE_EXPORT unsigned int hexToUInt (const std::string &str);
177 
181  DCMTREE_EXPORT int toInt (const std::string &str);
182 
186  DCMTREE_EXPORT unsigned int toUInt (const std::string &str);
187 
191  DCMTREE_EXPORT double toDouble (const std::string &str);
192 
196  DCMTREE_EXPORT std::string toString(const DCMTree::Vr vr);
197 
202  DCMTREE_EXPORT DCMTree::Vr toVr(const std::string& vrString);
203 
205  DCMTREE_EXPORT void toStream (std::ostream &out,const std::string &val);
206  DCMTREE_EXPORT void toStream (std::ostream &out,const int &val);
207  DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned int &val);
208  DCMTREE_EXPORT void toStream (std::ostream &out,const bool &val);
209  DCMTREE_EXPORT void toStream (std::ostream &out,const unsigned char *ptr,unsigned int size);
210 
212  DCMTREE_EXPORT void fromStream (std::istream &in,std::string &val);
213  DCMTREE_EXPORT void fromStream (std::istream &in,int &val);
214  DCMTREE_EXPORT void fromStream (std::istream &in,unsigned int &val);
215  DCMTREE_EXPORT void fromStream (std::istream &in,bool &val);
216  DCMTREE_EXPORT void fromStream (std::istream &in,unsigned char *ptr,unsigned int size);
217 
218  typedef void (*LoggingHandler) (std::string, int);
219 
225  DCMTREE_EXPORT void logMessage( std::string message, int errorCode = 0 );
226 
227  DCMTREE_EXPORT std::string condGetNameForTag(DCMTree::TagId tag, const std::string &defaultName);
228 }
229 
230 #endif
231 
232 
#define DCMTREE_EXPORT
Class to wrap a tag-id.
Definition: DCMTree_TagId.h:40
the delegate who is responsible for loading the specific DICOM library used in initialization,...
Definition: DCMTree_Utils.h:72
dictionary class to provide dicom-meta information
DCMTREE_EXPORT StringList split(const std::string &tosplit, char c, bool skipempties=false)
split the given string at each c if skipempties is true, all empty results would be removed
DCMTREE_EXPORT DCMTree::Time toTime(const std::string &str)
convert a string to time
DCMTREE_EXPORT unsigned int hexToUInt(const std::string &str)
convert a hex-string to unsigned int
DCMTREE_EXPORT int hexToInt(const std::string &str)
convert a hex-string to int
DCMTREE_EXPORT std::string digitsOnly(const std::string &str, bool allowhex=false)
remove all non-digits from the given strings if allowhex is true 'a'-'f','A'-'F' are preserved too
DCMTREE_EXPORT DCMTree::Date toDate(const std::string &str)
convert a string to date
std::list< std::string > StringList
a list of strings
Definition: DCMTree_Utils.h:92
DCMTREE_EXPORT void logMessage(std::string message, int errorCode=0)
Log a message using the provided callback, if any.
DCMTREE_EXPORT std::string toString(const DCMTree::Date &date)
convert a date to a string
DCMTREE_EXPORT double toDouble(const std::string &str)
convert a string to double
bool configLoadDll(std::string dllPath)
load a dynamic library from the specified path returns true on success else false
DCMTREE_EXPORT std::string beforeFractionPart(const std::string &str)
get the part of the string before the right-most dot if there is no dot in the string the result is t...
DCMTREE_EXPORT LoggingHandler getLoggingHandler()
Get the currently set logging callback.
void(* LoggingHandler)(std::string, int)
DCMTREE_EXPORT int toInt(const std::string &str)
convert a string to int
const std::list< std::string > configLibraryPathList(const std::string &installPath)
get list of paths where to search for dynamic libraries
DCMTREE_EXPORT void configLoadLibraries(LoadLibraryDelegate *delegate=nullptr)
load dynamic libraries, search in file DCMTree.cfg for their names
DCMTREE_EXPORT DCMTree::Vr toVr(const std::string &vrString)
convert a string into vr.
DCMTREE_EXPORT void fromStream(std::istream &in, std::string &val)
helpers to get data out of a stream
DCMTREE_EXPORT std::string afterFractionPart(const std::string &str)
get the part of the string after the right-most dot if there is no dot in the string the result is em...
DCMTREE_EXPORT unsigned int toUInt(const std::string &str)
convert a string to unsigned int
const std::string configInstallPath()
get 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)
Set a callback for logging purposes.
DCMTREE_EXPORT void toStream(std::ostream &out, const std::string &val)
helpers to put data into a stream
DCMTREE_EXPORT DCMTree::DateTime toDateTime(const std::string &str)
convert a string to datetime
std::pair< Date, Time > DateTime
DateTime.
Definition: DCMTree_Lib.h:201
Vr
DICOM VR.
Definition: DCMTree_Lib.h:208
Date class for DCMTree library.
Definition: DCMTree_Lib.h:181
Time class for DCMTree library.
Definition: DCMTree_Lib.h:191