+
+/*
+ * \brief canonical Writer
+ */
+void ValEntry::Write(std::ofstream* fp, FileType filetype)
+{
+ DocEntry::Write(fp, filetype);
+
+ //std::cout << "=====================================" << GetVR() << std::endl;
+
+ if ( GetGroup() == 0xfffe )
+ {
+ return; //delimitors have NO value
+ }
+
+ std::string vr = GetVR();
+ int lgr = GetReadLength();
+ if (vr == "US" || vr == "SS")
+ {
+ // some 'Short integer' fields may be mulivaluated
+ // each single value is separated from the next one by '\'
+ // we split the string and write each value as a short int
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Util::Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ uint16_t val_uint16 = atoi(tokens[i].c_str());
+ binary_write( *fp, val_uint16);
+ }
+ tokens.clear();
+ return;
+ }
+ if (vr == "UL" || vr == "SL")
+ {
+ // Some 'Integer' fields may be multivaluated (multiple instances
+ // of integers). But each single integer value is separated from the
+ // next one by '\' (backslash character). Hence we split the string
+ // along the '\' and write each value as an int:
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Util::Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ uint32_t val_uint32 = atoi(tokens[i].c_str());
+ binary_write( *fp, val_uint32);
+ }
+ tokens.clear();
+ return;
+ }
+
+ //Due to seriously broken Theralys images I cannot put that here.
+ //assert( lgr == GetValue().size() );
+ binary_write(*fp, GetValue());
+}