Console test harness menu.
More...
#include <consolemenu.hpp>
|
| ConsoleMenu (const F8MetaCntx &ctx, std::istream &is=std::cin, std::ostream &os=std::cout, int lpp=20) |
|
virtual | ~ConsoleMenu () |
| Dtor. More...
|
|
virtual F8API const BaseMsgEntry * | SelectMsg () const |
|
virtual F8API const FieldTable::Pair * | SelectField (const Message *msg, int groupid=0) const |
|
virtual F8API int | SelectRealm (const unsigned short fnum, const RealmBase *rb) const |
|
F8API Message * | SelectFromMsg (const MsgList &lst) const |
|
virtual F8API int | CreateMsgs (tty_save_state &tty, MsgList &lst) const |
|
F8API int | CreateMsgsFrom (tty_save_state &tty, MsgList &lst, const MsgList &from) const |
|
F8API Message * | RemoveMsg (tty_save_state &tty, MsgList &lst) const |
|
F8API void | EditMsg (tty_save_state &tty, const FieldTable::Pair *fld, Message *msg) const |
|
virtual F8API int | EditMsgs (tty_save_state &tty, MsgList &lst) const |
|
virtual F8API int | DeleteMsgs (tty_save_state &tty, MsgList &lst) const |
|
virtual F8API int | DeleteAllMsgs (tty_save_state &tty, MsgList &lst) const |
|
int | get_lpp () const |
|
void | set_lpp (int lpp) |
|
bool | get_yn (const f8String &prompt, bool echo=false) const |
|
char | get_key (const f8String &prompt=std::string(), bool echo=false) const |
|
F8API f8String & | GetString (tty_save_state &tty, f8String &to) const |
|
Console test harness menu.
Definition at line 48 of file consolemenu.hpp.
FIX8::ConsoleMenu::ConsoleMenu |
( |
const F8MetaCntx & |
ctx, |
|
|
std::istream & |
is = std::cin , |
|
|
std::ostream & |
os = std::cout , |
|
|
int |
lpp = 20 |
|
) |
| |
|
inline |
Ctor
- Parameters
-
ctx | - reference to generated metadata |
is | - reference to input stream |
os | - reference to output stream |
lpp | - lines to print per page |
Definition at line 62 of file consolemenu.hpp.
const F8MetaCntx & ctx()
Compiler generated metadata object, accessed through this function.
virtual FIX8::ConsoleMenu::~ConsoleMenu |
( |
| ) |
|
|
inlinevirtual |
Definition at line 302 of file consolemenu.cpp.
References FIX8::BaseMsgEntry::_create, and FIX8::Minst::_do.
309 unique_ptr<Message> msg(mc->_create._do(
true));
313 _os << endl << endl << *static_cast<MessageBase *>(msg.get()) << endl;
314 if (
get_yn(
"Add to list? (y/n):",
true))
315 lst.push_back(msg.release());
318 return static_cast<int>(lst.size());
Message instantiation table entry.
Pair abstraction for use with GeneratedTable.
Definition at line 279 of file consolemenu.cpp.
References FIX8::BaseMsgEntry::_create, and FIX8::Minst::_do.
286 unique_ptr<Message> msg(mc->_create._do(
true));
289 fmsg->copy_legal(msg.get());
293 _os << endl << endl << *static_cast<MessageBase *>(msg.get()) << endl;
294 if (
get_yn(
"Add to list? (y/n):",
true))
295 lst.push_back(msg.release());
298 return static_cast<int>(lst.size());
Message instantiation table entry.
Pair abstraction for use with GeneratedTable.
A complete Fix message with header, body and trailer.
Definition at line 408 of file consolemenu.cpp.
410 if (lst.size() &&
get_yn(
"Delete all msgs? (y/n):",
true))
412 for_each(lst.begin(), lst.end(), [](
const Message *pp){
delete pp; pp =
nullptr; });
A complete Fix message with header, body and trailer.
Definition at line 420 of file consolemenu.cpp.
427 for (MsgList::iterator itr(lst.begin()); itr != lst.end(); ++itr)
431 if (
get_yn(
" Delete msg? (y/n):",
true))
441 return static_cast<int>(lst.size());
A complete Fix message with header, body and trailer.
Definition at line 332 of file consolemenu.cpp.
References FIX8::_pair< Key, Val >::_key, FIX8::_pair< Key, Val >::_value, FIX8::MessageBase::add_field(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::MessageBase::find_group(), FIX8::MessageBase::get_fp(), FIX8::FieldTraits::get_presence(), FIX8::BaseField::get_tag(), and FIX8::FieldTraits::is_group().
340 _os << endl << fld->
_value._name <<
": " << flush;
348 for (
int ii(0); ii < cnt; ++ii)
350 Message *gmsg(static_cast<Message *>(gb->create_group(
true)));
354 _os << endl << endl << *static_cast<MessageBase *>(gmsg) << endl;
355 if (
get_yn(
"Add group to msg? (y/n):",
true))
Pair abstraction for use with GeneratedTable.
GroupBase * find_group() const
const Presence & get_presence() const
Abstract base class for all repeating groups.
A complete Fix message with header, body and trailer.
bool is_group(const unsigned short field, Presence::const_iterator &itr) const
const FieldTraits & get_fp() const
void add_field(const unsigned short fnum, Presence::const_iterator itr, const unsigned pos, BaseField *what, bool check)
The base field class (ABC) for all fields.
Definition at line 367 of file consolemenu.cpp.
377 _os << endl << endl << *static_cast<MessageBase *>(msg) << endl;
380 return static_cast<int>(lst.size());
Pair abstraction for use with GeneratedTable.
A complete Fix message with header, body and trailer.
char FIX8::ConsoleMenu::get_key |
( |
const f8String & |
prompt = std::string() , |
|
|
bool |
echo = false |
|
) |
| const |
|
inline |
int FIX8::ConsoleMenu::get_lpp |
( |
| ) |
const |
|
inline |
bool FIX8::ConsoleMenu::get_yn |
( |
const f8String & |
prompt, |
|
|
bool |
echo = false |
|
) |
| const |
|
inline |
Definition at line 384 of file consolemenu.cpp.
References FIX8::Message::clone().
389 for (MsgList::iterator itr(lst.begin()); itr != lst.end(); ++itr)
394 if (
get_yn(
"Remove msg from list? (y/n, n=return a copy):",
true))
A complete Fix message with header, body and trailer.
Definition at line 101 of file consolemenu.cpp.
References FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::at(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::begin(), FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::end(), FIX8::MessageBase::get_fp(), FIX8::MessageBase::get_msgtype(), FIX8::FieldTraits::get_presence(), FIX8::MessageBase::have(), FIX8::FieldTraits::is_mandatory(), FIX8::MessageBase::print_field(), and FIX8::presorted_set< unsigned short, FieldTrait, FieldTrait::Compare >::size().
105 ostr << msg->
get_msgtype() <<
" (" << grpid <<
')';
114 _os <<
"--------------------------------------------------" << endl;
115 _os <<
' ' << ostr.str() <<
": Select field to add (*:mandatory +:present)" << endl;
116 _os <<
"--------------------------------------------------" << endl;
123 if (msg->
have(itr->_fnum))
131 << tbe->_name <<
'(' << itr->_fnum <<
')' << endl;
152 if ((idx = _opt_keys.find_first_of(opt)) != f8String::npos)
154 idx += (page *
_lpp);
bool have(const unsigned short fnum) const
const_iterator find_pair_ptr(const Key &key) const
virtual F8API void print_field(const unsigned short fnum, std::ostream &os) const
bool is_mandatory(const unsigned short field) const
const Presence & get_presence() const
Used for static trait interrogation.
const_iterator at(const size_t idx) const
const f8String & get_msgtype() const
const FieldTraits & get_fp() const
const Val * find_ptr(const Key &key) const
Definition at line 218 of file consolemenu.cpp.
References FIX8::_pair< Key, Val >::_key, and FIX8::_pair< Key, Val >::_value.
225 MsgList::const_iterator itr(lst.begin());
228 _os <<
"--------------------------------------------------" << endl;
229 _os <<
"Select from " << lst.size() <<
" messages" << endl;
230 _os <<
"--------------------------------------------------" << endl;
233 for (
unsigned nlines(0); itr != lst.end(); ++itr)
240 if ((*itr)->Header())
242 (*itr)->Header()->get(sndtime);
243 (*itr)->Header()->get(msgseqnum);
245 _os <<
'[' <<
_opt_keys[nlines] <<
"] " << tbme->_value._name <<
'(' << tbme->_key <<
")\t"
246 << sndtime() <<
' ' << msgseqnum() <<
' ' << txt() << endl;
249 if (nlines %
_lpp == 0 || (nlines +
_lpp * page) == lst.size())
251 _os <<
"Page " << (page + 1) <<
' ';
266 if ((idx =
_opt_keys.find_first_of(opt)) != f8String::npos)
268 idx += (page *
_lpp);
269 if (idx < lst.size())
const_iterator find_pair_ptr(const Key &key) const
Pair abstraction for use with GeneratedTable.
Field template. There will ONLY be partial template specialisations of this template.
Definition at line 50 of file consolemenu.cpp.
References FIX8::_pair< Key, Val >::_value.
57 _os <<
"--------------------------------------------------" << endl;
58 _os <<
" Select message to create" << endl;
59 _os <<
"--------------------------------------------------" << endl;
62 for (
unsigned nlines(0); pp !=
_ctx.
_bme.
end(); ++pp)
64 _os <<
'[' <<
_opt_keys[nlines] <<
"] " << pp->_value._name <<
'(' << pp->_key <<
')' << endl;
84 if ((idx =
_opt_keys.find_first_of(opt)) != f8String::npos)
const_iterator begin() const
Pair abstraction for use with GeneratedTable.
const_iterator at(const size_t idx) const
const_iterator end() const
int ConsoleMenu::SelectRealm |
( |
const unsigned short |
fnum, |
|
|
const RealmBase * |
rb |
|
) |
| const |
|
virtual |
Definition at line 166 of file consolemenu.cpp.
References FIX8::RealmBase::_descriptions, FIX8::RealmBase::_sz, and FIX8::RealmBase::print().
176 _os <<
"--------------------------------------------------" << endl;
177 _os <<
' ' << be->_name <<
": Select realm value to add" << endl;
178 _os <<
"--------------------------------------------------" << endl;
181 for (
int nlines(0); pp < rb->
_sz; ++pp)
188 if (nlines %
_lpp == 0 || (nlines +
_lpp * page) == rb->
_sz)
190 _os <<
"Page " << (page + 1) <<
'/' << (1 + (rb->
_sz /
_lpp)) <<
' ';
205 if (static_cast<size_t>((idx = (static_cast<int>(
_opt_keys.find_first_of(opt))))) != f8String::npos)
207 idx += (page *
_lpp);
std::ostream & print(std::ostream &os, int idx) const
const char *const * _descriptions
void FIX8::ConsoleMenu::set_lpp |
( |
int |
lpp | ) |
|
|
inline |
std::istream& FIX8::ConsoleMenu::_is |
|
private |
int FIX8::ConsoleMenu::_lpp |
|
private |
std::ostream& FIX8::ConsoleMenu::_os |
|
private |
The documentation for this class was generated from the following files: