GDCM 3.0.24
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
19namespace 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);
46 typedef String<'\\',16> InternalClass;
47public:
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
78protected:
79 std::string TrimInternal() const {
80 return Internal.Trim();
81 }
82
83private:
84 String<'\\',16> Internal;
85};
86
87inline std::ostream& operator<< (std::ostream& os, const CodeString& str)
88{
89 os << str.Internal;
90 return os;
91}
92
93inline bool operator==(const CodeString &ref, const CodeString& cs)
94{
95 return ref.Internal == cs.Internal;
96}
97inline 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
CodeString.
Definition gdcmCodeString.h:42
InternalClass::const_reverse_iterator const_reverse_iterator
Definition gdcmCodeString.h:57
InternalClass::reverse_iterator reverse_iterator
Definition gdcmCodeString.h:56
std::string TrimInternal() const
Definition gdcmCodeString.h:79
CodeString()
CodeString constructors.
Definition gdcmCodeString.h:60
InternalClass::iterator iterator
Definition gdcmCodeString.h:54
CodeString(const value_type *s)
Definition gdcmCodeString.h:61
InternalClass::difference_type difference_type
Definition gdcmCodeString.h:53
InternalClass::reference reference
Definition gdcmCodeString.h:50
InternalClass::pointer pointer
Definition gdcmCodeString.h:49
bool IsValid() const
Check if CodeString obj is correct..
InternalClass::const_reference const_reference
Definition gdcmCodeString.h:51
InternalClass::const_iterator const_iterator
Definition gdcmCodeString.h:55
InternalClass::size_type size_type
Definition gdcmCodeString.h:52
std::string GetAsString() const
Return the full code string as std::string.
Definition gdcmCodeString.h:71
size_type Size() const
Return the size of the string.
Definition gdcmCodeString.h:76
CodeString(const InternalClass &s, size_type pos=0, size_type n=InternalClass::npos)
Definition gdcmCodeString.h:64
CodeString(const value_type *s, size_type n)
Definition gdcmCodeString.h:62
InternalClass::value_type value_type
Definition gdcmCodeString.h:48
String.
Definition gdcmString.h:32
std::string::value_type value_type
Definition gdcmString.h:38
std::string::size_type size_type
Definition gdcmString.h:42
std::string::const_reference const_reference
Definition gdcmString.h:41
std::string::iterator iterator
Definition gdcmString.h:44
std::string::pointer pointer
Definition gdcmString.h:39
std::string::reverse_iterator reverse_iterator
Definition gdcmString.h:46
std::string::difference_type difference_type
Definition gdcmString.h:43
std::string::const_reverse_iterator const_reverse_iterator
Definition gdcmString.h:47
std::string::const_iterator const_iterator
Definition gdcmString.h:45
std::string::reference reference
Definition gdcmString.h:40
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21
bool operator==(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:93
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88
bool operator!=(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:97