Main Page | File List | Related Pages

gdcmVR.cxx

00001 // gdcmVR.cxx
00002 #include <fstream>
00003 //-----------------------------------------------------------------------------
00004 #include "gdcmVR.h"
00005 #include "gdcmUtil.h"
00006 
00007 #ifndef PUB_DICT_PATH
00008 #  define PUB_DICT_PATH     "../Dicts/"
00009 #endif
00010 #define DICT_VR "dicomVR.dic"
00011 
00012 #include <iostream>
00013 #ifdef GDCM_NO_ANSI_STRING_STREAM
00014 #  include <strstream>
00015 #  define  ostringstream ostrstream
00016 # else
00017 #  include <sstream>
00018 #endif
00019 
00020 //-----------------------------------------------------------------------------
00021 // Constructor / Destructor
00022 gdcmVR::gdcmVR(void) 
00023 {
00024    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
00025    std::ifstream from(filename.c_str());
00026    dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str());
00027 
00028    char buff[1024];
00029    std::string key;
00030    std::string name;
00031 
00032    while (!from.eof()) 
00033    {
00034       eatwhite(from);
00035       from.getline(buff, 1024, ' ');
00036       key = buff;
00037       eatwhite(from);
00038       from.getline(buff, 1024, ';');
00039       name = buff;
00040 
00041       eatwhite(from);
00042       from.getline(buff, 1024, '\n');
00043 
00044       if(key!="")
00045       {
00046          vr[key]=name;
00047       }
00048    }
00049    from.close();
00050 }
00051 
00052 gdcmVR::~gdcmVR() {
00053    vr.clear();
00054 }
00055 
00056 //-----------------------------------------------------------------------------
00057 // Print
00063 void gdcmVR::Print(std::ostream &os) 
00064 {
00065    std::ostringstream s;
00066 
00067    for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
00068    {
00069       s << "VR : "<<it->first<<" = "<<it->second<<std::endl;
00070    }
00071    os << s.str();
00072 }
00073 
00074 //-----------------------------------------------------------------------------
00075 // Public
00081 int gdcmVR::Count(VRKey key) 
00082 {
00083    return vr.count(key);
00084 }
00085 
00086 //-----------------------------------------------------------------------------
00087 // Protected
00088 
00089 //-----------------------------------------------------------------------------
00090 // Private
00091 
00092 //-----------------------------------------------------------------------------

Generated on Mon Feb 14 16:13:44 2005 for gdcm by doxygen 1.3.6