GDCM
2.2.3
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 00005 Copyright (c) 2006-2011 Mathieu Malaterre 00006 All rights reserved. 00007 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 #ifndef GDCMCODESTRING_H 00015 #define GDCMCODESTRING_H 00016 00017 #include "gdcmString.h" 00018 00019 namespace gdcm 00020 { 00021 00039 // Note to myself: because note all wrapped language support exception 00040 // we could not support throwing an exception during object construction. 00041 class GDCM_EXPORT CodeString 00042 { 00043 friend std::ostream& operator<< (std::ostream& os, const CodeString& str); 00044 friend bool operator==(const CodeString &ref, const CodeString& cs); 00045 friend bool operator!=(const CodeString &ref, const CodeString& cs); 00046 typedef String<'\\',16> InternalClass; 00047 public: 00048 typedef InternalClass::value_type value_type; 00049 typedef InternalClass::pointer pointer; 00050 typedef InternalClass::reference reference; 00051 typedef InternalClass::const_reference const_reference; 00052 typedef InternalClass::size_type size_type; 00053 typedef InternalClass::difference_type difference_type; 00054 typedef InternalClass::iterator iterator; 00055 typedef InternalClass::const_iterator const_iterator; 00056 typedef InternalClass::reverse_iterator reverse_iterator; 00057 typedef InternalClass::const_reverse_iterator const_reverse_iterator; 00058 00060 CodeString(): Internal() {} 00061 CodeString(const value_type* s): Internal(s) { Internal = Internal.Trim(); } 00062 CodeString(const value_type* s, size_type n): Internal(s, n) { 00063 Internal = Internal.Trim(); } 00064 CodeString(const InternalClass& s, size_type pos=0, size_type n=InternalClass::npos): 00065 Internal(s, pos, n) { Internal = Internal.Trim(); } 00066 00068 bool IsValid() const; 00069 00071 std::string GetAsString() const { 00072 return Internal; 00073 } 00074 00076 size_type Size() const { return Internal.size(); } 00077 00078 protected: 00079 std::string TrimInternal() const { 00080 return Internal.Trim(); 00081 } 00082 00083 private: 00084 String<'\\',16> Internal; 00085 }; 00086 00087 inline std::ostream& operator<< (std::ostream& os, const CodeString& str) 00088 { 00089 os << str.Internal; 00090 return os; 00091 } 00092 00093 inline bool operator==(const CodeString &ref, const CodeString& cs) 00094 { 00095 return ref.Internal == cs.Internal; 00096 } 00097 inline bool operator!=(const CodeString &ref, const CodeString& cs) 00098 { 00099 return ref.Internal != cs.Internal; 00100 } 00101 00102 00103 } // end namespace gdcm 00104 00105 #endif //GDCMCODESTRING_H