vega
padded_string_manipulator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "vega/uid.h"
5 #include "vega/string.h"
6 
7 #include <vector>
8 #include <string>
9 
10 // AE: char, space padded, backslash delimited
11 // Application Entity
12 // AS: char (4 bytes), space padding, backslash delimiter
13 // Age String
14 // CS: char (leading/trailing spaces non-significant), space padding, backslash delimiter
15 // Code string
16 // DA: char (8 bytes), space padding, backslash delimiter
17 // Date (YYYYMMDD)
18 // DS: char (max 16 bytes), space padding, backslash delimiter
19 // Decimal string
20 // DT: char (max 26 bytes), space padding, backslash delimiter
21 // Datetime (YYYYMMDDHHMMSS.FFFFFF&ZZXX)
22 // IS: char (max 12), space padding, backslash delimiter
23 // Integer string
24 // LO: char (max 64), space padding, backslash delimiter
25 // Long string
26 // LT: char (max 10240, allow backslash), space padding, no delimiter (VM == 1)
27 // Long text
28 // PN: char (max 64), space padding, backslash delimiter
29 // Person name
30 // SH: char (max 16 leading/trailing space insignificant), space padding, backslash delimiter
31 // Short string
32 // ST: char (max 1024, allow backslash, trailing space insignificant), space padding, no delimiter (VM == 1)
33 // Short text
34 // TM: char (max 16), space padding, backslash delimiter
35 // Time (HHMMSS.FFFFFF)
36 // UI: char (max 64), null padding, backslash delimiter
37 // Attribute Tag
38 
39 // UT: char (unlimited), space padding, no delimiter (VM == 1)
40 // Attribute Tag
41 
42 // AT: two uint16_t, no padding, no delimiter
43 // Attribute Tag
44 // FL: float32, no padding, no delimiter
45 // Floating point
46 // FD: double64, no padding, no delimiter
47 // Floating point double
48 // SL: int32_t, no padding, no delimiter
49 // Signed long
50 // SS: int16_t, no padding, no delimiter
51 // Signed short
52 // UL: uint32_t, no padding, no delimiter
53 // Unsigned long
54 // US: uint16_t, no padding, no delimiter
55 // Unsigned short
56 
57 // OB: bytes, null padding, no delimiter necessary
58 // Other byte string
59 // OD: double64, no padding, no delimiter
60 // Other double string
61 // OF: float32, no padding, no delimiter
62 // Other float string
63 // OW: 16bit words, no padding, no delimiter
64 // Other word string
65 
66 // SQ: DataSets, no padding, no delimiter
67 // Sequence
68 
69 // UN: bytes, no padding, no delimiter
70 // Unknown
71 
72 // ox: OB or OF
73 // xs: SS or US
74 // xw: SS or US or OW
75 // uw: US or OW
76 
77 namespace vega {
78  namespace manipulators {
88  template <typename T>
89  class PaddedStringManipulator : public ValueManipulator, private std::vector<T> {
90  private:
91  typedef std::vector<T> base_vector;
92 
93  public:
94  typedef typename base_vector::value_type value_type;
95  typedef typename base_vector::size_type size_type;
96  typedef typename base_vector::iterator iterator;
97  typedef typename base_vector::const_iterator const_iterator;
98  typedef typename base_vector::reference reference;
99  typedef typename base_vector::const_reference const_reference;
100 
101  using base_vector::operator[];
102  using base_vector::at;
103 
104  using base_vector::clear;
105  using base_vector::erase;
106  using base_vector::reserve;
107  using base_vector::resize;
108  using base_vector::size;
109  using base_vector::begin;
110  using base_vector::end;
111  using base_vector::front;
112  using base_vector::back;
113  using base_vector::push_back;
114  using base_vector::emplace_back;
115 
117  explicit PaddedStringManipulator(std::shared_ptr<dicom::RawValue> raw_value);
118  explicit PaddedStringManipulator(const std::string& s);
119 
120  std::shared_ptr<dicom::RawValue> raw_value() override;
121  std::string str() const override;
122  bool read_from(dicom::RawReader* reader, size_t num_bytes) override;
123  size_t write_to(dicom::RawWriter* writer) const override;
124 
125  virtual bool operator==(const ValueManipulator& other) const override;
126  virtual bool operator!=(const ValueManipulator& other) const override;
127 
128  private:
129  // For parsing all elements from the raw DICOM string (including delimiters)
130  void parse_from_string(const std::string& s);
131  };
132  }
133 }
134 
virtual bool operator!=(const ValueManipulator &other) const override
Definition: padded_string_manipulator_impl.h:94
base_vector::size_type size_type
Definition: padded_string_manipulator.h:95
base_vector::value_type value_type
Definition: padded_string_manipulator.h:94
PaddedStringManipulator()
Definition: padded_string_manipulator_impl.h:9
std::shared_ptr< dicom::RawValue > raw_value() override
Definition: padded_string_manipulator_impl.h:26
virtual bool operator==(const ValueManipulator &other) const override
Definition: padded_string_manipulator_impl.h:86
bool read_from(dicom::RawReader *reader, size_t num_bytes) override
Definition: padded_string_manipulator_impl.h:55
base_vector::const_reference const_reference
Definition: padded_string_manipulator.h:99
Definition: value_manipulator.h:29
size_t write_to(dicom::RawWriter *writer) const override
Definition: padded_string_manipulator_impl.h:80
base_vector::reference reference
Definition: padded_string_manipulator.h:98
base_vector::iterator iterator
Definition: padded_string_manipulator.h:96
Definition: age.h:6
A manipulator class for VR that represent elements which are encoded in DICOM using strings...
Definition: padded_string_manipulator.h:89
std::string str() const override
Definition: padded_string_manipulator_impl.h:31
base_vector::const_iterator const_iterator
Definition: padded_string_manipulator.h:97