Repository navigation
Expand file tree
/
Copy pathValueToFix.cpp
More file actions
205 lines (173 loc) · 4.52 KB
/
Copy pathValueToFix.cpp
File metadata and controls
205 lines (173 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// Copyright (c) 2009, Object Computing, Inc.
// All rights reserved.
// See the file license.txt for licensing information.
//
#include <Examples/ExamplesPch.h>
#include "ValueToFix.h"
#include <Messages/FieldIdentity.h>
#include <Common/Decimal.h>
using namespace QuickFAST;
using namespace Examples;
ValueToFix::ValueToFix(std::ostream & out, const char * recordSeparator)
: out_(out)
, recordSeparator_(recordSeparator)
, logLevel_(Common::Logger::QF_LOG_WARNING)
{
}
ValueToFix::~ValueToFix()
{
}
bool
ValueToFix::wantLog(unsigned short level)
{
return level <= logLevel_;
}
bool
ValueToFix::logMessage(unsigned short level, const std::string & logMessage)
{
if(level <= logLevel_)
{
std::cerr << logMessage << std::endl;
}
return true;
}
bool
ValueToFix::reportDecodingError(const std::string & errorMessage)
{
std::cerr << "Decoding error: " << errorMessage << std::endl;
return false;
}
bool
ValueToFix::reportCommunicationError(const std::string & errorMessage)
{
//out_
std::cerr << "Communication error: " << errorMessage << std::endl;
return false;
}
const std::string &
ValueToFix::getApplicationType()const
{
return applicationType_;
}
const std::string &
ValueToFix::getApplicationTypeNs()const
{
return applicationTypeNamespace_;
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const int64 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const uint64 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const int32 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const uint32 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const int16 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const uint16 value)
{
out_ << identity.id() << '=' << value << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const int8 value)
{
out_ << identity.id() << '=' << (short)(value) << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const uchar value)
{
out_ << identity.id() << '=' << (unsigned short)(value) << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const Decimal& value)
{
std::string v;
value.toString(v);
out_ << identity.id() << '=' << v << '\x01';
}
void
ValueToFix::addValue(const Messages::FieldIdentity & identity, ValueType::Type type, const unsigned char * value, size_t length)
{
out_ << identity.id() << '=' << std::string(reinterpret_cast<const char *>(value), length) << '\x01';
}
Messages::ValueMessageBuilder &
ValueToFix::startMessage(
const std::string & applicationType,
const std::string & applicationTypeNamespace,
size_t size)
{
applicationType_ = applicationType;
applicationTypeNamespace_ = applicationTypeNamespace;
return *this;
}
bool
ValueToFix::endMessage(Messages::ValueMessageBuilder & messageBuilder)
{
out_ << recordSeparator_;
return true;
}
bool
ValueToFix::ignoreMessage(Messages::ValueMessageBuilder & messageBuilder)
{
return true;
}
Messages::ValueMessageBuilder &
ValueToFix::startSequence(
const Messages::FieldIdentity & identity,
const std::string & applicationType,
const std::string & applicationTypeNamespace,
size_t fieldCount,
const Messages::FieldIdentity & lengthIdentity,
size_t length)
{
return *this;
}
void
ValueToFix::endSequence(
const Messages::FieldIdentity & identity,
Messages::ValueMessageBuilder & sequenceBuilder)
{
}
Messages::ValueMessageBuilder &
ValueToFix::startSequenceEntry(
const std::string & applicationType,
const std::string & applicationTypeNamespace,
size_t size)
{
return *this;
}
void
ValueToFix::endSequenceEntry(Messages::ValueMessageBuilder & entry)
{
}
Messages::ValueMessageBuilder &
ValueToFix::startGroup(
const Messages::FieldIdentity & identity,
const std::string & applicationType,
const std::string & applicationTypeNamespace,
size_t size)
{
return *this;
}
void
ValueToFix::endGroup(
const Messages::FieldIdentity & identity,
Messages::ValueMessageBuilder & groupBuilder)
{
}