Main Page | File List | Related Pages

gdcmTS.cxx

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

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