OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
FieldValueRef.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
25 
26 namespace OnixS
27 {
28  namespace Eurex
29  {
30  namespace MarketData
31  {
32 
33  ONIXS_EUREX_EMDI_API_DECL (class, Message);
34  ONIXS_EUREX_EMDI_API_DECL (class, Group);
35 
36  /// Implements concept of a read-only
37  /// reference to a FIX field value.
38  class
39  ONIXS_EUREX_EMDI_API
41  {
42  public:
43  /// Uninitialized value.
44  FieldValueRef();
45 
46  /// Shallow copy from another one.
47  FieldValueRef (const FieldValueRef& other);
48 
49  /// Indicated whether the instance
50  /// refers to a valid value.
51  operator bool() const;
52 
53  /// Return string presentation
54  /// of the value being referenced.
55  operator std::string() const;
56 
57  /// Compares with another instance for equality.
58  bool operator == (const FieldValueRef&) const;
59 
60  /// Compares with another instance for inequality.
61  bool operator != (const FieldValueRef&) const;
62 
63  /// Compares string presentation for
64  /// equality with given text reference.
65  bool operator == (const StringRef&) const;
66 
67  /// Compares string presentation for
68  /// equality with given text reference.
69  bool operator != (const StringRef&) const;
70 
71  /// Converts field value into whole number.
72  ///
73  /// @return false if conversion fails.
74  ///
75  /// @warning Due to performance considerations
76  /// doesn't check whether instance refers to a valid
77  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
78  /// member to check instance for a validness.
79  bool toNumber (Int32&) const;
80 
81  /// Converts field value into whole number.
82  ///
83  /// @return false if conversion fails.
84  ///
85  /// @warning Due to performance considerations
86  /// doesn't check whether instance refers to a valid
87  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
88  /// member to check instance for a validness.
89  bool toNumber (UInt32&) const;
90 
91  /// Converts field value into whole number.
92  ///
93  /// @return false if conversion fails.
94  ///
95  /// @warning Due to performance considerations
96  /// doesn't check whether instance refers to a valid
97  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
98  /// member to check instance for a validness.
99  bool toNumber (Int64&) const;
100 
101  /// Converts field value into whole number.
102  ///
103  /// @return false if conversion fails.
104  ///
105  /// @warning Due to performance considerations
106  /// doesn't check whether instance refers to a valid
107  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
108  /// member to check instance for a validness.
109  bool toNumber (UInt64&) const;
110 
111  /// Converts field value into floating point value.
112  ///
113  /// @return false if conversion fails.
114  ///
115  /// @warning Due to performance considerations
116  /// doesn't check whether instance refers to a valid
117  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
118  /// member to check instance for a validness.
119  bool toNumber (Decimal&) const;
120 
121  /// Converts field value into timestamp of requested format.
122  ///
123  /// @return false if conversion fails.
124  ///
125  /// @warning Due to performance considerations
126  /// doesn't check whether instance refers to a valid
127  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
128  /// member to check instance for a validness.
129  bool
130  toTimestamp (
131  Timestamp&,
134 
135  /// If value represents text, returns reference to it.
136  ///
137  /// @return false if conversion fails (for example,
138  /// stored value is whole number assigned to a field
139  /// using OnixS::FIX::FieldSet::setV member).
140  ///
141  /// @warning Due to performance considerations
142  /// doesn't check whether instance refers to a valid
143  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
144  /// member to check instance for a validness.
145  bool toStringRef (StringRef&) const;
146 
147  /// If value represent one-char text,
148  /// copies it into given variable.
149  ///
150  /// @return false if conversion fails (for example,
151  /// stored value is whole number assigned to a field
152  /// using OnixS::FIX::FieldSet::setV member).
153  ///
154  /// @warning Due to performance considerations
155  /// doesn't check whether instance refers to a valid
156  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
157  /// member to check instance for a validness.
158  bool toChar (char&) const;
159 
160  /// If repeating group is associated with
161  /// field, allows to get instance of it.
162  ///
163  /// @return false if no group is associated with field.
164  ///
165  /// @warning Due to performance considerations
166  /// doesn't check whether instance refers to a valid
167  /// value. Use OnixS::FIX::FieldValueRef::operator bool()
168  /// member to check instance for a validness.
169  bool toGroup (Group&) const;
170 
171  /// Appends copy of text presentation to the std::string.
172  void toString (std::string&) const;
173 
174  /// Return string presentation of field value.
175  std::string toString() const;
176 
177  /// Updates instance to refer to another field value.
178  /// @warning Does NOT perform deep copy of field values.
179  /// Just updates reference to point to value of other field.
180  FieldValueRef& operator = (const FieldValueRef&);
181 
182  ///
183  void swap(FieldValueRef&) throw();
184 
185  private:
186  friend class MessageOperator;
187 
188  const void* impl_;
189 
190  const Message* container_;
191 
192  FieldValueRef (
193  const Message*,
194  const void*);
195  };
196 
197  inline
198  FieldValueRef::
199  operator std::string() const
200  {
201  std::string str;
202 
203  toString (str);
204 
205  return str;
206  }
207 
208  inline
209  std::string
211  {
212  std::string str;
213 
214  toString (str);
215 
216  return str;
217  }
218 
219  // More comparison operators.
220 
221  inline
222  bool
224  const FieldValueRef& ref,
225  const std::string& str)
226  {
227  return ref == StringRef (str);
228  }
229 
230  inline
231  bool
233  const FieldValueRef& ref,
234  const std::string& str)
235  {
236  return ref != StringRef (str);
237  }
238 
239  inline
240  bool
242  const std::string& str,
243  const FieldValueRef& ref)
244  {
245  return ref == StringRef (str);
246  }
247 
248  inline
249  bool
251  const std::string& str,
252  const FieldValueRef& ref)
253  {
254  return ref != StringRef (str);
255  }
256 
257  // More comparison operators.
258 
259  inline
260  bool
262  const FieldValueRef& ref,
263  const char* str)
264  {
265  return ref == StringRef (str);
266  }
267 
268  inline
269  bool
271  const FieldValueRef& ref,
272  const char* str)
273  {
274  return ref != StringRef (str);
275  }
276 
277  inline
278  bool
280  const char* str,
281  const FieldValueRef& ref)
282  {
283  return ref == StringRef (str);
284  }
285 
286  inline
287  bool
289  const char* str,
290  const FieldValueRef& ref)
291  {
292  return ref != StringRef (str);
293  }
294  }
295  }
296 }
297 
bool operator==(const FieldValueRef &ref, const std::string &str)
unsigned int UInt32
Definition: Numeric.h:41
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
Represents timestamp without time-zone information.
Definition: Timestamp.h:80
ONIXS_EUREX_EMDI_API_DECL(class, Message)
std::string toString() const
Return string presentation of field value.
bool operator==(const FieldValueRef &) const
Compares with another instance for equality.
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition: Timestamp.h:75
bool operator!=(const FieldValueRef &) const
Compares with another instance for inequality.
bool operator!=(const FieldValueRef &ref, const std::string &str)