GDCM  2.0.18
gdcmCodeString.h
Go to the documentation of this file.
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   GDCM_LEGACY(std::string Trim() const)
00077 
00078   
00079   size_type Size() const { return Internal.size(); }
00080 
00083   GDCM_LEGACY(size_type size() const)
00084 
00085 protected:
00086   std::string TrimInternal() const {
00087     return Internal.Trim();
00088   }
00089 
00090 private:
00091   String<'\\',16> Internal;
00092 };
00093 
00094 inline std::ostream& operator<< (std::ostream& os, const CodeString& str)
00095 {
00096   os << str.Internal;
00097   return os;
00098 }
00099 
00100 inline bool operator==(const CodeString &ref, const CodeString& cs)
00101 {
00102   return ref.Internal == cs.Internal;
00103 }
00104 inline bool operator!=(const CodeString &ref, const CodeString& cs)
00105 {
00106   return ref.Internal != cs.Internal;
00107 }
00108 
00109 
00110 } // end namespace gdcm
00111 
00112 #endif //GDCMCODESTRING_H

Generated on Tue Dec 6 2011 07:25:31 for GDCM by doxygen 1.7.5.1
SourceForge.net Logo