GDCM: gdcmCodeString.h Source File

GDCM 3.2.8

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.
41 class GDCM_EXPORT CodeString
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:
48 typedef InternalClass::value_type value_type;
49 typedef InternalClass::pointer pointer;
50 typedef InternalClass::reference reference;
51 typedef InternalClass::const_reference const_reference;
52 typedef InternalClass::size_type size_type;
53 typedef InternalClass::difference_type difference_type;
54 typedef InternalClass::iterator iterator;
55 typedef InternalClass::const_iterator const_iterator;
56 typedef InternalClass::reverse_iterator reverse_iterator;
57 typedef InternalClass::const_reverse_iterator const_reverse_iterator;
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
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
gdcm::CodeString::const_reverse_iterator
InternalClass::const_reverse_iterator const_reverse_iterator
Definition gdcmCodeString.h:57
gdcm::CodeString::reverse_iterator
InternalClass::reverse_iterator reverse_iterator
Definition gdcmCodeString.h:56
gdcm::CodeString::TrimInternal
std::string TrimInternal() const
Definition gdcmCodeString.h:79
gdcm::CodeString::CodeString
CodeString()
CodeString constructors.
Definition gdcmCodeString.h:60
gdcm::CodeString::iterator
InternalClass::iterator iterator
Definition gdcmCodeString.h:54
gdcm::CodeString::CodeString
CodeString(const value_type *s)
Definition gdcmCodeString.h:61
gdcm::CodeString::difference_type
InternalClass::difference_type difference_type
Definition gdcmCodeString.h:53
gdcm::CodeString::reference
InternalClass::reference reference
Definition gdcmCodeString.h:50
gdcm::CodeString::operator!=
friend bool operator!=(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:97
gdcm::CodeString::pointer
InternalClass::pointer pointer
Definition gdcmCodeString.h:49
gdcm::CodeString::IsValid
bool IsValid() const
Check if CodeString obj is correct..
gdcm::CodeString::operator==
friend bool operator==(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:93
gdcm::CodeString::const_reference
InternalClass::const_reference const_reference
Definition gdcmCodeString.h:51
gdcm::CodeString::const_iterator
InternalClass::const_iterator const_iterator
Definition gdcmCodeString.h:55
gdcm::CodeString::size_type
InternalClass::size_type size_type
Definition gdcmCodeString.h:52
gdcm::CodeString::GetAsString
std::string GetAsString() const
Return the full code string as std::string.
Definition gdcmCodeString.h:71
gdcm::CodeString::Size
size_type Size() const
Return the size of the string.
Definition gdcmCodeString.h:76
gdcm::CodeString::CodeString
CodeString(const InternalClass &s, size_type pos=0, size_type n=InternalClass::npos)
Definition gdcmCodeString.h:64
gdcm::CodeString::CodeString
CodeString(const value_type *s, size_type n)
Definition gdcmCodeString.h:62
gdcm::CodeString::value_type
InternalClass::value_type value_type
Definition gdcmCodeString.h:48
gdcm::String
String.
Definition gdcmString.h:32
gdcm::String<'\\', 16 >::value_type
std::string::value_type value_type
Definition gdcmString.h:38
gdcm::String<'\\', 16 >::size_type
std::string::size_type size_type
Definition gdcmString.h:42
gdcm::String<'\\', 16 >::const_reference
std::string::const_reference const_reference
Definition gdcmString.h:41
gdcm::String<'\\', 16 >::iterator
std::string::iterator iterator
Definition gdcmString.h:44
gdcm::String<'\\', 16 >::pointer
std::string::pointer pointer
Definition gdcmString.h:39
gdcm::String<'\\', 16 >::reverse_iterator
std::string::reverse_iterator reverse_iterator
Definition gdcmString.h:46
gdcm::String<'\\', 16 >::difference_type
std::string::difference_type difference_type
Definition gdcmString.h:43
gdcm::String<'\\', 16 >::const_reverse_iterator
std::string::const_reverse_iterator const_reverse_iterator
Definition gdcmString.h:47
gdcm::String<'\\', 16 >::const_iterator
std::string::const_iterator const_iterator
Definition gdcmString.h:45
gdcm::String<'\\', 16 >::reference
std::string::reference reference
Definition gdcmString.h:40
gdcmString.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21
gdcm::operator==
bool operator==(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:93
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88
gdcm::operator!=
bool operator!=(const CodeString &ref, const CodeString &cs)
Definition gdcmCodeString.h:97