-using namespace std;
-
-// Library globals.
-gdcmDebug dbg;
-
-gdcmDebug::gdcmDebug(int level) {
- DebugLevel = level;
-}
-
-void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
- if (Level > DebugLevel)
- return ;
- std::cerr << Msg1 << ' ' << Msg2 << '\n';
-}
-
-void gdcmDebug::Assert(int Level, bool Test,
- const char * Msg1, const char * Msg2) {
- if (Level > DebugLevel)
- return ;
- if (!Test)
- std::cerr << Msg1 << ' ' << Msg2 << '\n';
-}
-
-void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
- if (!Test)
- return;
- std::cerr << Msg1 << ' ' << Msg2 << '\n';
- Exit(1);
+#include "gdcmDebug.h"
+
+#include <stdarg.h> //only included in implementation file
+#include <stdio.h> //only included in implementation file
+
+namespace gdcm
+{
+
+/**
+ * \ingroup Globals
+ * \brief Provide a better 'c++' approach for sprintf
+ * For example c code is:
+ * sprintf(trash, "%04x|%04x", group , element);
+ *
+ * c++ is
+ * std::ostringstream buf;
+ * buf << std::right << std::setw(4) << std::setfill('0') << std::hex
+ * << group << "|" << std::right << std::setw(4) << std::setfill('0')
+ * << std::hex << element;
+ * buf.str();
+ */
+
+std::string Util::Format(const char* format, ...)
+{
+ char buffer[2048];
+ va_list args;
+ va_start(args, format);
+ vsprintf(buffer, format, args); //might be a security flaw
+ return buffer;
+}
+
+
+/**
+ * \ingroup Globals
+ * \brief Because not available in C++ (?)
+ */
+void Util::Tokenize (const std::string& str,
+ std::vector<std::string>& tokens,
+ const std::string& delimiters)
+{
+ std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
+ std::string::size_type pos = str.find_first_of (delimiters,lastPos);
+ while (std::string::npos != pos || std::string::npos != lastPos)
+ {
+ tokens.push_back(str.substr(lastPos, pos - lastPos));
+ lastPos = str.find_first_not_of(delimiters, pos);
+ pos = str.find_first_of (delimiters, lastPos);
+ }