GDCM  2.2.0
gdcmCodeString.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: GDCM (Grassroots DICOM). A DICOM library
4 
5  Copyright (c) 2006-2011 Mathieu Malaterre
6  All rights reserved.
7  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMCODESTRING_H
15 #define GDCMCODESTRING_H
16 
17 #include "gdcmString.h"
18 
19 namespace gdcm
20 {
21 
39 // Note to myself: because note all wrapped language support exception
40 // we could not support throwing an exception during object construction.
42 {
43  friend std::ostream& operator<< (std::ostream& os, const CodeString& str);
44  friend bool operator==(const CodeString &ref, const CodeString& cs);
45  friend bool operator!=(const CodeString &ref, const CodeString& cs);
47 public:
58 
60  CodeString(): Internal() {}
61  CodeString(const value_type* s): Internal(s) { Internal = Internal.Trim(); }
62  CodeString(const value_type* s, size_type n): Internal(s, n) {
63  Internal = Internal.Trim(); }
64  CodeString(const InternalClass& s, size_type pos=0, size_type n=InternalClass::npos):
65  Internal(s, pos, n) { Internal = Internal.Trim(); }
66 
68  bool IsValid() const;
69 
71  std::string GetAsString() const {
72  return Internal;
73  }
74 
76  size_type Size() const { return Internal.size(); }
77 
78 protected:
79  std::string TrimInternal() const {
80  return Internal.Trim();
81  }
82 
83 private:
84  String<'\\',16> Internal;
85 };
86 
87 inline std::ostream& operator<< (std::ostream& os, const CodeString& str)
88 {
89  os << str.Internal;
90  return os;
91 }
92 
93 inline bool operator==(const CodeString &ref, const CodeString& cs)
94 {
95  return ref.Internal == cs.Internal;
96 }
97 inline bool operator!=(const CodeString &ref, const CodeString& cs)
98 {
99  return ref.Internal != cs.Internal;
100 }
101 
102 
103 } // end namespace gdcm
104 
105 #endif //GDCMCODESTRING_H

Generated on Wed Jun 13 2012 20:40:37 for GDCM by doxygen 1.8.1
SourceForge.net Logo