deprecated eatwhite I wasn't able to find the ref in any c++ refs, only microsoft implement it, thus fallback to a more standart c++ approach. This is mainly to get rid of any 'c' like include header
- and some minor cleanups
Program: gdcm
Module: $RCSfile: gdcmDicomDirElement.cxx,v $
Language: C++
- Date: $Date: 2004/09/27 08:39:06 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/10/08 04:43:37 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
-#include <fstream>
-#include <stdio.h> // For sprintf
-#include <iostream>
-
#include "gdcmDicomDirElement.h"
#include "gdcmUtil.h"
#include "gdcmDebug.h"
#include "gdcmDictSet.h"
+#include <fstream>
+#include <stdio.h> // For sprintf
+#include <iostream>
//-----------------------------------------------------------------------------
// Constructor / Destructor
while (!from.eof())
{
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
from.getline(buff, 1024, ' ');
type = buff;
{
from >> std::hex >> elem.group >> elem.elem;
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
from.getline(buff, 1024, '"');
- eatwhite(from);
+ from >> std::ws; // Used to be eatwhite(from);
from.getline(buff, 1024, '"');
elem.value = buff;
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2004/09/27 08:39:06 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2004/10/08 04:43:38 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
from >> element;
from >> vr;
from >> fourth;
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
std::getline(from, name); /// MEMORY LEAK in std::getline<>
gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
Program: gdcm
Module: $RCSfile: gdcmTS.cxx,v $
Language: C++
- Date: $Date: 2004/09/27 08:39:07 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2004/10/08 04:43:38 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
-#include <fstream>
-#include <string>
-#include <iostream>
-
#include "gdcmTS.h"
#include "gdcmDebug.h"
#include "gdcmUtil.h"
#include "gdcmDictSet.h"
-
+#include <fstream>
+#include <string>
+#include <iostream>
//-----------------------------------------------------------------------------
// Constructor / Destructor
-gdcmTS::gdcmTS(void)
+gdcmTS::gdcmTS()
{
std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_TS);
std::ifstream from(filename.c_str());
std::string key;
std::string name;
- while (!from.eof()) {
+ while (!from.eof())
+ {
from >> key;
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
std::getline(from, name); /// MEMORY LEAK
- if(key!="")
+ if(key!="")
{
ts[key]=name;
}
from.close();
}
+//-----------------------------------------------------------------------------
gdcmTS::~gdcmTS()
{
ts.clear();
std::string gdcmTS::GetValue(TSKey key)
{
- if (ts.count(key) == 0)
+ if (ts.count(key) == 0)
+ {
return GDCM_UNFOUND;
+ }
return ts[key];
}
Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2004/09/27 08:39:08 $
- Version: $Revision: 1.50 $
+ Date: $Date: 2004/10/08 04:43:38 $
+ Version: $Revision: 1.51 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmUtil.h"
#include "gdcmDebug.h"
-#include <stdio.h>
-#include <ctype.h> // For isspace
-#include <string.h> // CLEANME: could this be only string ? Related to Win32 ?
-#include <iostream>
-
-/**
- * \ingroup Globals
- * \brief Because is not yet available in g++2.96
- */
-std::istream& eatwhite(std::istream& is) {
- char c;
- while (is.get(c)) {
- if (!isspace(c)) {
- is.putback(c);
- break;
- }
- }
- return is;
-}
/**
* \ingroup Globals
*/
void Tokenize (const std::string& str,
std::vector<std::string>& tokens,
- const std::string& delimiters) {
+ 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) {
+ 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);
* Counts the number of occurences of a substring within a string
*/
- int CountSubstring (const std::string& str,
- const std::string& subStr) {
+int CountSubstring (const std::string& str,
+ const std::string& subStr)
+{
int count = 0; // counts how many times it appears
unsigned int x = 0; // The index position in the string
do
- { x = str.find(subStr,x); // Find the substring
+ {
+ x = str.find(subStr,x); // Find the substring
if (x != std::string::npos) // If present
- { count++; // increase the count
- x += subStr.length(); // Skip this word
- }
- }
+ {
+ count++; // increase the count
+ x += subStr.length(); // Skip this word
+ }
+ }
while (x != std::string::npos); // Carry on until not present
return count;
* to avoid corrupting the terminal of invocation when printing)
* @param s string to remove non printable characters from
*/
-std::string CreateCleanString(std::string s) {
- std::string str=s;
+std::string CreateCleanString(std::string s)
+{
+ std::string str = s;
for(unsigned int i=0;i<str.size();i++)
{
if(!isprint(str[i]))
+ {
str[i]='.';
+ }
}
if(str.size()>0)
+ {
if(!isprint(s[str.size()-1]))
+ {
if(s[str.size()-1]==0)
+ {
str[str.size()-1]=' ';
+ }
+ }
+ }
return str;
}
const char SEPARATOR_X = '/';
const char SEPARATOR_WIN = '\\';
const std::string SEPARATOR = "/";
- int size=name.size();
+ int size = name.size();
if((name[size-1]!=SEPARATOR_X)&&(name[size-1]!=SEPARATOR_WIN))
{
{
fullName.resize(pos2);
}
+
return fullName;
}
*/
std::string GetName(std::string &fullName)
{
- int fin=fullName.length()-1;
- char a =fullName.c_str()[fin];
- if (a == '/' || a == '\\') {
- fin--;
- }
- int deb = 0;
- for (int i=fin;i!=0;i--) {
- if (fullName.c_str()[i] == '/' || fullName.c_str()[i] == '\\')
- break;
+ int fin = fullName.length()-1;
+ char a =fullName.c_str()[fin];
+ if (a == '/' || a == '\\')
+ {
+ fin--;
+ }
+ int deb = 0;
+ for (int i=fin;i!=0;i--)
+ {
+ if (fullName.c_str()[i] == '/' || fullName.c_str()[i] == '\\')
+ {
+ break;
+ }
deb = i;
- }
+ }
- std::string lastName;
- for (int j=deb;j<fin+1;j++)
- lastName=lastName+fullName.c_str()[j];
+ std::string lastName;
+ for (int j=deb;j<fin+1;j++)
+ {
+ lastName=lastName+fullName.c_str()[j];
+ }
return lastName;
}
Program: gdcm
Module: $RCSfile: gdcmUtil.h,v $
Language: C++
- Date: $Date: 2004/10/07 21:05:40 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2004/10/08 04:43:38 $
+ Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
//-----------------------------------------------------------------------------
-GDCM_EXPORT std::istream & eatwhite(std::istream & is);
-
GDCM_EXPORT void Tokenize (const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = " ");
Program: gdcm
Module: $RCSfile: gdcmVR.cxx,v $
Language: C++
- Date: $Date: 2004/09/27 08:39:08 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2004/10/08 04:43:38 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
-#include <fstream>
-
-#include <iostream>
-
#include "gdcmVR.h"
#include "gdcmUtil.h"
#include "gdcmDictSet.h"
#include "gdcmDebug.h"
+#include <fstream>
+#include <iostream>
+
//-----------------------------------------------------------------------------
/**
* \brief Constructor
*/
-gdcmVR::gdcmVR(void)
+gdcmVR::gdcmVR()
{
std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
std::ifstream from(filename.c_str());
while (!from.eof())
{
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
from.getline(buff, 1024, ' ');
key = buff;
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
from.getline(buff, 1024, ';');
name = buff;
- eatwhite(from);
+ from >> std::ws; // used to be eatwhite(from);
from.getline(buff, 1024, '\n');
if(key!="")
from.close();
}
+//-----------------------------------------------------------------------------
/**
* \brief Destructor
*/
-gdcmVR::~gdcmVR() {
+gdcmVR::~gdcmVR()
+{
vr.clear();
}
return vr.count(key);
}
+//-----------------------------------------------------------------------------
/**
* \brief Simple predicate that checks wether the given argument
* corresponds to the Value Representation of a \ref gdcmBinEntry .
return true;
}
+//-----------------------------------------------------------------------------
/**
* \brief Simple predicate that checks wether the given argument
* corresponds to the Value Representation of a \ref gdcmValEntry