-gdcmDict::gdcmDict(const char* FileName) {
- std::ifstream from(FileName);
- dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary", FileName);
- guint16 group, element;
- // CLEANME : use defines for all those constants
- char buff[1024];
- TagKey key;
- TagName vr;
- TagName fourth;
- TagName name;
- while (!from.eof()) {
- from >> hex >> group >> element;
- eatwhite(from);
- from.getline(buff, 256, ' ');
- vr = buff;
- eatwhite(from);
- from.getline(buff, 256, ' ');
- fourth = buff;
- from.getline(buff, 256, '\n');
- name = buff;
- gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
- vr, fourth, name);
- NameHt[name] = newEntry;
- KeyHt[gdcmDictEntry::TranslateToKey(group, element)] = newEntry;
- }
- from.close();
+/**
+ * \brief Constructor
+ * @param filename from which to build the dictionary.
+ */
+Dict::Dict(std::string const &filename)
+{
+ uint16_t group;
+ uint16_t element;
+ TagName vr;
+ TagName vm;
+ TagName name;
+
+ std::ifstream from( filename.c_str() );
+ if( !from )
+ {
+ gdcmVerboseMacro( "Can't open dictionary" << filename.c_str());
+ // Using default embeded one:
+ FillDefaultDataDict( this );
+ }
+ else
+ {
+ while (!from.eof())
+ {
+ from >> std::hex;
+ from >> group;
+ from >> element;
+ from >> vr;
+ from >> vm;
+ from >> std::ws; //remove white space
+ std::getline(from, name);
+
+ const DictEntry newEntry(group, element, vr, vm, name);
+ AddEntry(newEntry);
+ }
+
+ Filename = filename;
+ from.close();
+ }