+ if( !from )
+ {
+ gdcmWarningMacro("Can't open dictionary" << filename.c_str());
+ FillDefaultTSDict( TsMap );
+ }
+ else
+ {
+ TSKey key;
+ TSAtr name;
+
+ while (!from.eof())
+ {
+ from >> key;
+ from >> std::ws;
+ std::getline(from, name);
+
+ if(key != "")
+ {
+ TsMap[key] = name;
+ }
+ }
+ from.close();
+ }
+}
+
+TS::~TS()
+{
+ TsMap.clear();
+}
+
+//-----------------------------------------------------------------------------
+// Public
+
+/// \brief returns occurence number of the given key
+int TS::Count(TSKey const &key)
+{
+ return TsMap.count(key);
+}
+
+/// \brief returns the human reabable value of a Transfer Synatx string
+TSAtr const &TS::GetValue(TSKey const &key)
+{
+ // First thing clean up the string
+ // (sometime the transfer syntax is padded with spaces)
+ std::string copy = key;
+ while ( copy.size() && !isdigit((unsigned char)copy[copy.size()-1]) )
+ {
+ copy.erase(copy.size()-1, 1);
+ }
+
+ TSHT::const_iterator it = TsMap.find(copy);
+ if (it == TsMap.end())
+ {
+ return GDCM_UNFOUND;
+ }
+ return it->second;
+}
+/**
+ * \brief Determines if the key passed corresponds to a 'Transfer Syntax'
+ * as defined in DICOM (and stored in gdcm::TS class)
+ * @return True when key is an actual 'Transfer Syntax'. False in all
+ * other cases.
+ */
+bool TS::IsTransferSyntax(TSKey const &key)
+{
+ TSHT::const_iterator it = TsMap.find(key);
+ return it != TsMap.end();
+}
+
+/**
+ * \brief Determines if the Transfer Syntax was already encountered
+ * and if it corresponds to a Run Length Encoding Lossless one
+ * @return True when Run Length Encoding Lossless found. False in all
+ * other cases.
+ */
+bool TS::IsRLELossless(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[RLELossless] )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+/**
+ * \brief Determines if the Transfer Syntax was already encountered
+ * and if it corresponds to a 'classical' JPEG Lossless one
+ * @return True when 'classical' Lossless found. False in all
+ * other cases.
+ */
+bool TS::IsJPEGLossless(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[JPEGFullProgressionProcess10_12]
+ || key == SpecialStrings[JPEGLosslessProcess14]
+ || key == SpecialStrings[JPEGLosslessProcess14_1] )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+/**
+ * \brief Determines if the Transfer Syntax was already encountered
+ * and if it corresponds to a 'classical' JPEG Lossy one
+ * @return True when 'classical' Lossy found. False in all
+ * other cases.
+ */
+bool TS::IsJPEGLossy(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[JPEGBaselineProcess1]
+ || key == SpecialStrings[JPEGExtendedProcess2_4]
+ || key == SpecialStrings[JPEGExtendedProcess3_5]
+ || key == SpecialStrings[JPEGSpectralSelectionProcess6_8] )
+ {
+ r = true;
+ }
+ }
+ return r;
+}