MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
44namespace DCMTree_Utils
45{
49 const std::string configInstallPath();
50
54 const std::list<std::string> configLibraryPathList(const std::string& installPath);
55
61 {
62 public:
64 virtual bool loadDICOMLibraries() = 0;
65 };
66
71 bool configLoadDll(std::string dllPath);
72
77
81 typedef std::list<std::string> StringList;
82
87 DCMTREE_EXPORT StringList split(const std::string& tosplit, char c, bool skipempties = false);
88
93
97 DCMTREE_EXPORT std::string toString(const DCMTree::Time& time);
98
103
107 DCMTREE_EXPORT std::string toString(int val);
108
112 DCMTREE_EXPORT std::string toString(unsigned int val);
113
118 DCMTREE_EXPORT std::string toString(float val);
119
123 DCMTREE_EXPORT std::string toString(double val);
124
129
134
139
144 DCMTREE_EXPORT std::string digitsOnly(const std::string& str, bool allowhex = false);
145
150 DCMTREE_EXPORT std::string afterFractionPart(const std::string& str);
151
156 DCMTREE_EXPORT std::string beforeFractionPart(const std::string& str);
157
161 DCMTREE_EXPORT int hexToInt(const std::string& str);
162
166 DCMTREE_EXPORT unsigned int hexToUInt(const std::string& str);
167
171 DCMTREE_EXPORT int toInt(const std::string& str);
172
176 DCMTREE_EXPORT unsigned int toUInt(const std::string& str);
177
181 DCMTREE_EXPORT double toDouble(const std::string& str);
182
186 DCMTREE_EXPORT std::string toString(const DCMTree::Vr vr);
187
193
195 DCMTREE_EXPORT void toStream(std::ostream& out, const std::string& val);
196 DCMTREE_EXPORT void toStream(std::ostream& out, const int& val);
197 DCMTREE_EXPORT void toStream(std::ostream& out, const unsigned int& val);
198 DCMTREE_EXPORT void toStream(std::ostream& out, const bool& val);
199 DCMTREE_EXPORT void toStream(std::ostream& out, const unsigned char* ptr, unsigned int size);
200
202 DCMTREE_EXPORT void fromStream(std::istream& in, std::string& val, size_t maxSize = 0);
203 DCMTREE_EXPORT void fromStream(std::istream& in, int& val);
204 DCMTREE_EXPORT void fromStream(std::istream& in, unsigned int& val);
205 DCMTREE_EXPORT void fromStream(std::istream& in, bool& val);
206 DCMTREE_EXPORT void fromStream(std::istream& in, unsigned char* ptr, unsigned int size);
207
208 typedef void (*LoggingHandler)(std::string, int);
209
215 DCMTREE_EXPORT void logMessage(std::string message, int errorCode = 0);
216
218} // namespace DCMTree_Utils
219
220#endif
#define DCMTREE_EXPORT
Class to wrap a tag ID.
The delegate that is responsible for loading the specific DICOM library.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
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.
const std::list< std::string > configLibraryPathList(const std::string &installPath)
Returns a list of paths to search for dynamic libraries.
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.
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.
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.
Vr
DICOM VR.
std::pair< Date, Time > DateTime
DateTime.
Date class for DCMTree library.
Time class for DCMTree library.