OnixS C++ Tullett Prebon SURF Handler  1.6.1
API documentation
FieldValue.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
13  * part of this source code or associated reference material to any other location for further
14  * reproduction or redistribution, and any amendments to this copyright notice, are expressly
15  * prohibited.
16  *
17  * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18  * the terms of the Agreement is a violation of copyright law.
19  */
20 
21 #pragma once
22 
24 #include <OnixS/SURF/MarketData/Export.h>
25 
26 #include <iosfwd>
27 #include <string>
28 
29 namespace OnixS { namespace SURF { namespace MarketData {
30 
31 /// Date.
32 struct ONIXS_TP_SURF_EXPORT Date
33 {
34  /// Initialize default instance.
35  Date();
36 
37  /// Initializes a new instance to the specified year, month, and day.
38  /// \param day The day (1 through the number of days in month).
39  /// \param month The month (1 through 12).
40  /// \param year The year (1 through 9999).
41  /// \throw ArgumentRangeException If year is less than 1 or greater
42  /// than 9999 - or - month is less than 1 or greater than 12 - or -
43  /// day is less than 1 or greater than the number of days in month.
44  Date(int year, int month, int day);
45 
46  /// The year component of the date represented by this instance.
47  int year;
48 
49  /// The month component of the date represented by this instance.
50  int month;
51 
52  /// The day of the month represented by this instance.
53  int day;
54 
55  /// Returns string representation.
56  std::string toString() const;
57 };
58 
59 ONIXS_TP_SURF_EXPORT std::ostream& operator<<(std::ostream&, const Date&);
60 
61 /// Time.
62 struct ONIXS_TP_SURF_EXPORT Time
63 {
64  /// Initialize default instance.
65  Time();
66 
67  /// Initializes a new instance to the specified year, month, and day.
68  /// \param hour The hours (0 through 23).
69  /// \param minute The minutes (0 through 59).
70  /// \throw ArgumentRangeException If hour is less than 0 or greater than 23 - or - minute is
71  /// less than 0 or greater than 59.
72  Time(int hour, int minute);
73 
74  /// The hour component of the date represented by this instance.
75  int hour;
76 
77  /// The minute component of the date represented by this instance.
78  int minute;
79 
80  /// Returns string representation.
81  std::string toString() const;
82 };
83 
84 ONIXS_TP_SURF_EXPORT std::ostream& operator<<(std::ostream&, const Time&);
85 
86 /// Field value.
87 struct ONIXS_TP_SURF_EXPORT FieldValue
88 {
89  /// Indicates whether array of zero length.
90  bool empty() const;
91 
92  /// Returns the field value as a string.
93  std::string toString() const;
94 
95  /// Returns field value as an int value.
96  ///
97  /// \throw std::exception if conversion is impossible.
98  int toInt32() const;
99 
100  /// Returns field value as an 'unsigned int' value.
101  ///
102  /// \throw std::exception if conversion is impossible.
103  unsigned int toUInt32() const;
104 
105  /// Returns field value as an 'long long' value.
106  ///
107  /// \throw std::exception if conversion is impossible.
108  long long toInt64() const;
109 
110  /// Returns field value as an 'unsigned long long' value.
111  ///
112  /// \throw std::exception if conversion is impossible.
113  unsigned long long toUInt64() const;
114 
115  /// Returns the field value as a floating-point number.
116  ///
117  /// \throw std::exception if conversion is impossible.
118  double toDouble() const;
119 
120  /// Returns the field value as a decimal number.
121  ///
122  /// \throw std::exception if conversion is impossible.
123  Decimal toDecimal() const;
124 
125  /// Returns the field value as Date.
126  ///
127  /// \throw std::exception if conversion is impossible.
128  Date toDate() const;
129 
130  /// Returns the field value as Time.
131  ///
132  /// \throw std::exception if conversion is impossible.
133  Time toTime() const;
134 
135 protected:
136  FieldValue(const char* data, size_t length);
137  FieldValue(const FieldValue& value);
138  FieldValue& operator=(const FieldValue& value);
139 
140 private:
141  const char* data_;
142  size_t length_;
143 };
144 
145 ONIXS_TP_SURF_EXPORT std::ostream& operator<<(std::ostream&, const FieldValue&);
146 
147 }}} // namespace OnixS::SURF::MarketData
int hour
The hour component of the date represented by this instance.
Definition: FieldValue.h:75
int minute
The minute component of the date represented by this instance.
Definition: FieldValue.h:78
int day
The day of the month represented by this instance.
Definition: FieldValue.h:53
Definition: Decimal.h:28
int year
The year component of the date represented by this instance.
Definition: FieldValue.h:47
int month
The month component of the date represented by this instance.
Definition: FieldValue.h:50
std::ostream & operator<<(std::ostream &, const Decimal &)