OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Screen Struct Reference

Classes

struct  DeleteLast

Public Types

enum class  Direction

Static Public Member Functions

static void init ()
static DeleteLast deleteLast (size_t n)
static std::ostream & reset (std::ostream &os)
static std::ostream & bold (std::ostream &os)
static std::ostream & red (std::ostream &os)
static std::ostream & green (std::ostream &os)
static std::ostream & yellow (std::ostream &os)
static std::ostream & black (std::ostream &os)
static std::ostream & onRed (std::ostream &os)
static std::ostream & onGreen (std::ostream &os)
static std::ostream & onYellow (std::ostream &os)
static std::ostream & onCyan (std::ostream &os)
static std::ostream & onWhite (std::ostream &os)
static std::ostream & out ()
template<typename T>
static T getInput (const T &defaultValue={})
template<typename... Args>
static void info (const Args &... args)
template<typename... Args>
static void error (const Args &... args)
template<typename... Args>
static void warning (const Args &... args)
template<typename... Args>
static void trace (const Args &... args)
template<typename... Args>
static void out (const Args &... args)
static void printProgress (size_t cur, size_t total)
static std::string toStr (Direction direction)
static void traceMsg (const std::string &sessionId, SbeMessage message, Direction direction)
template<typename ItemType>
static void outItems (const ItemType &items)
template<typename ItemType>
static void outList (const ItemType &list)
static std::chrono::milliseconds sinceLstUpdate ()

Friends

std::ostream & operator<< (std::ostream &os, const DeleteLast &m)

Detailed Description

Definition at line 46 of file CUI.h.

Member Enumeration Documentation

◆ Direction

enum class Direction
strong
Enumerator
In 
Out 

Definition at line 200 of file CUI.h.

200{In, Out};

Member Function Documentation

◆ black()

std::ostream & black ( std::ostream & os)
inlinestatic

Definition at line 94 of file CUI.h.

95 {
96 if(vtMode()) os << "\x1b[30m";
97 return os;
98 }

◆ bold()

std::ostream & bold ( std::ostream & os)
inlinestatic

Definition at line 70 of file CUI.h.

71 {
72 if(vtMode()) os << "\x1b[1m";
73 return os;
74 }

◆ deleteLast()

DeleteLast deleteLast ( size_t n)
inlinestatic

Definition at line 56 of file CUI.h.

56{return {n};}

◆ error()

template<typename... Args>
void error ( const Args &... args)
inlinestatic

Definition at line 155 of file CUI.h.

156 {
157 Guard g(mutex(), out());
158 out() << "\n" << bold << black << onRed << "[ERROR]" << reset << " " << append(args...) << "\n";
159 }
bool args(const Options &options, const Char *option, Iterator target, size_t minQty=0, size_t maxQty=static_cast< size_t >(-1))
Definition Options.h:345

◆ getInput()

template<typename T>
T getInput ( const T & defaultValue = {})
inlinestatic

Definition at line 136 of file CUI.h.

136 {})
137 {
138 std::string userInput;
139 std::getline(std::cin, userInput);
140
141 if (userInput.empty())
142 return defaultValue;
143
144 return Samples::parseUserInput<T>(userInput);
145 }
T parseUserInput(const std::string &userInput, typename std::enable_if< std::is_integral< T >::value, void * >::type=nullptr)
Definition Utils.h:142

◆ green()

std::ostream & green ( std::ostream & os)
inlinestatic

Definition at line 82 of file CUI.h.

83 {
84 if(vtMode()) os << "\x1b[38;2;0;255;64m";
85 return os;
86 }

◆ info()

template<typename... Args>
void info ( const Args &... args)
inlinestatic

Definition at line 148 of file CUI.h.

149 {
150 Guard g(mutex(), out());
151 out() << "\n" << bold << black << onGreen << "[INFO]" << reset << " " << append(args...) << "\n";
152 }

◆ init()

void init ( )
inlinestatic

Definition at line 48 of file CUI.h.

49 {
50#ifdef _WIN32
51 vtMode() = enableVtMode();
52#endif
53 }

◆ onCyan()

std::ostream & onCyan ( std::ostream & os)
inlinestatic

Definition at line 118 of file CUI.h.

119 {
120 if(vtMode()) os << "\x1b[48;2;150;210;220m";
121 return os;
122 }

◆ onGreen()

std::ostream & onGreen ( std::ostream & os)
inlinestatic

Definition at line 106 of file CUI.h.

107 {
108 if(vtMode()) os << "\x1b[48;2;120;200;150m";
109 return os;
110 }

◆ onRed()

std::ostream & onRed ( std::ostream & os)
inlinestatic

Definition at line 100 of file CUI.h.

101 {
102 if(vtMode()) os << "\x1b[48;2;210;120;120m";
103 return os;
104 }

◆ onWhite()

std::ostream & onWhite ( std::ostream & os)
inlinestatic

Definition at line 124 of file CUI.h.

125 {
126 if(vtMode()) os << "\x1b[48;2;240;240;240m";
127 return os;
128 }

◆ onYellow()

std::ostream & onYellow ( std::ostream & os)
inlinestatic

Definition at line 112 of file CUI.h.

113 {
114 if(vtMode()) os << "\x1b[48;2;235;220;160m";
115 return os;
116 }

◆ out() [1/2]

std::ostream & out ( )
inlinestatic

Definition at line 130 of file CUI.h.

131 {
132 return std::cout;
133 }

◆ out() [2/2]

template<typename... Args>
void out ( const Args &... args)
inlinestatic

Definition at line 176 of file CUI.h.

177 {
178 Guard g(mutex(), out());
179 out() << append(args...) << std::endl;
180 }

◆ outItems()

template<typename ItemType>
void outItems ( const ItemType & items)
inlinestatic

Definition at line 236 of file CUI.h.

237 {
238 Guard g(mutex(), out());
239
240 for (size_t index = 0; index < items.size(); ++index)
241 out() << "\t" << bold << black << onGreen << "[" << (index + 1) << "]" << reset << " " << items[index].text_ << "\n";
242 }

◆ outList()

template<typename ItemType>
void outList ( const ItemType & list)
inlinestatic

Definition at line 245 of file CUI.h.

246 {
247 Guard g(mutex(), out());
248
249 out() << "\t[";
250
251 bool first = true;
252 for (const auto& item : list)
253 {
254 if (!first)
255 out() << ",";
256
257 first = false;
258 out() << item;
259 }
260
261 out() << "]\n";
262 }

◆ printProgress()

void printProgress ( size_t cur,
size_t total )
inlinestatic

Definition at line 182 of file CUI.h.

183 {
184 Guard g(mutex(), out());
185
186 const size_t width = 40;
187
188 if (total == 0) total = 1;
189 cur = (std::min)(cur, total);
190
191 const double r = double(cur) / double(total);
192 const auto filled = static_cast<std::size_t>(r * width);
193
194 out() << '\r' << '[' << std::string(filled, '#') << std::string(width - filled, ' ')
195 << "] " << std::setw(3) << int(r * 100) << '%' << std::flush;
196
197 if (cur == total) out() << '\n';
198 }

◆ red()

std::ostream & red ( std::ostream & os)
inlinestatic

Definition at line 76 of file CUI.h.

77 {
78 if(vtMode()) os << "\x1b[38;2;255;64;64m";
79 return os;
80 }

◆ reset()

std::ostream & reset ( std::ostream & os)
inlinestatic

Definition at line 64 of file CUI.h.

65 {
66 if(vtMode()) os << "\x1b[0m";
67 return os;
68 }

◆ sinceLstUpdate()

std::chrono::milliseconds sinceLstUpdate ( )
inlinestatic

Definition at line 264 of file CUI.h.

265 {
266 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - lastUpdateTime());
267 }

◆ toStr()

std::string toStr ( Direction direction)
inlinestatic

Definition at line 202 of file CUI.h.

203 {
204#ifdef _WIN32
205 return direction == Direction::In ? "[<-]" : "[->]";
206#else
207 return direction == Direction::In ? "[←]" : "[→]";
208#endif
209 }

◆ trace()

template<typename... Args>
void trace ( const Args &... args)
inlinestatic

Definition at line 169 of file CUI.h.

170 {
171 Guard g(mutex(), out());
172 out() << "\n" << bold << black << onCyan << "[TRACE]" << reset << " " << append(args...) << "\n";
173 }

◆ traceMsg()

void traceMsg ( const std::string & sessionId,
SbeMessage message,
Direction direction )
inlinestatic

Definition at line 211 of file CUI.h.

212 {
213 Guard g(mutex(), out());
214
215 out() << "\n" << bold << black << onCyan << toStr(direction) << reset << " ";
216
217 out() << "[" << sessionId << "] ";
218
219 const auto printMsg = [&](const auto msg)
220 {
221 out() << msg.toString();
222
223 const auto text = formatMsg(msg);
224
225 if(!text.empty())
226 out() << "\n\t" << text;
227 };
228
229 if (!ONIXS_ICEBOE_MESSAGING_NAMESPACE::processTypified(message, printMsg))
230 out() << yellow << "Unknown message type [" << message.templateId() << "]" << reset;
231
232 out() << "\n";
233 }
std::string formatMsg(const Message message, typename std::enable_if< isFormattableMsg< Message >::value, void * >::type=nullptr)
Definition Formatting.h:85
std::string toStr(Order::PriceOptional value)
Definition Order.cpp:34

◆ warning()

template<typename... Args>
void warning ( const Args &... args)
inlinestatic

Definition at line 162 of file CUI.h.

163 {
164 Guard g(mutex(), out());
165 out() << "\n" << bold << black << onYellow << "[WARN]" << reset << " " << append(args...) << "\n";
166 }

◆ yellow()

std::ostream & yellow ( std::ostream & os)
inlinestatic

Definition at line 88 of file CUI.h.

89 {
90 if(vtMode()) os << "\x1b[38;2;255;255;64m";
91 return os;
92 }

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const DeleteLast & m )
friend

Definition at line 58 of file CUI.h.

59 {
60 if(vtMode()) os << "\x1b[" << m.n << "F" << "\x1b[" << m.n << "M" << std::flush;
61 return os;
62 }