fix8
version 1.4.0
Open Source C++ FIX Framework
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
consolemenu.hpp
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------------------
2
/*
3
4
Fix8 is released under the GNU LESSER GENERAL PUBLIC LICENSE Version 3.
5
6
Fix8 Open Source FIX Engine.
7
Copyright (C) 2010-16 David L. Dight <fix@fix8.org>
8
9
Fix8 is free software: you can redistribute it and / or modify it under the terms of the
10
GNU Lesser General Public License as published by the Free Software Foundation, either
11
version 3 of the License, or (at your option) any later version.
12
13
Fix8 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16
You should have received a copy of the GNU Lesser General Public License along with Fix8.
17
If not, see <http://www.gnu.org/licenses/>.
18
19
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO
20
THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
21
COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
22
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
24
THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
25
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
26
27
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT
28
HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED
29
ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
30
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
31
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
32
THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
33
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
34
35
*/
36
//-------------------------------------------------------------------------------------------------
37
#ifndef FIX8_CONSOLEMENU_HPP_
38
#define FIX8_CONSOLEMENU_HPP_
39
40
//-------------------------------------------------------------------------------------------------
41
namespace
FIX8
{
42
43
//-------------------------------------------------------------------------------------------------
44
using
MsgList
= std::deque<FIX8::Message *>;
45
46
//-------------------------------------------------------------------------------------------------
48
class
ConsoleMenu
49
{
50
const
F8MetaCntx
&
_ctx
;
51
std::istream&
_is
;
52
std::ostream&
_os
;
53
int
_lpp
;
54
static
const
f8String
_opt_keys
,
_fld_prompt
;
55
56
public
:
62
ConsoleMenu
(
const
F8MetaCntx
&
ctx
, std::istream& is=std::cin, std::ostream& os=std::cout,
int
lpp=20)
63
: _ctx(ctx), _is(is), _os(os), _lpp(lpp) {}
64
66
virtual
~ConsoleMenu
() {}
67
68
F8API
virtual
const
BaseMsgEntry
*
SelectMsg
()
const
;
69
F8API
virtual
const
FieldTable::Pair
*
SelectField
(
const
Message
*msg,
int
groupid = 0)
const
;
70
F8API
virtual
int
SelectRealm
(
const
unsigned
short
fnum,
const
RealmBase
*rb)
const
;
71
F8API
Message
*
SelectFromMsg
(
const
MsgList
& lst)
const
;
72
F8API
virtual
int
CreateMsgs
(
tty_save_state
& tty,
MsgList
& lst)
const
;
73
F8API
int
CreateMsgsFrom
(
tty_save_state
& tty,
MsgList
& lst,
const
MsgList
& from)
const
;
74
F8API
Message
*
RemoveMsg
(
tty_save_state
& tty,
MsgList
& lst)
const
;
75
F8API
void
EditMsg
(
tty_save_state
& tty,
const
FieldTable::Pair
*fld,
Message
*msg)
const
;
76
F8API
virtual
int
EditMsgs
(
tty_save_state
& tty,
MsgList
& lst)
const
;
77
F8API
virtual
int
DeleteMsgs
(
tty_save_state
& tty,
MsgList
& lst)
const
;
78
F8API
virtual
int
DeleteAllMsgs
(
tty_save_state
& tty,
MsgList
& lst)
const
;
79
80
int
get_lpp
()
const
{
return
_lpp
; }
81
void
set_lpp
(
int
lpp) { _lpp = lpp; }
82
83
bool
get_yn
(
const
f8String
& prompt,
bool
echo=
false
)
const
{
return
toupper(
get_key
(prompt, echo)) ==
'Y'
; }
84
char
get_key
(
const
f8String
& prompt=std::string(),
bool
echo=
false
)
const
85
{
86
char
ch(0);
87
_is.clear();
88
if
(!prompt.empty())
89
_os << prompt << std::flush;
90
_is.get(ch);
91
if
(!_is.bad() && ch != 0x3 && ch != 0xa)
92
{
93
if
(echo)
94
_os << ch;
95
return
ch;
96
}
97
return
0;
98
}
99
F8API
f8String
&
GetString
(
tty_save_state
& tty,
f8String
& to)
const
;
100
};
101
102
//-------------------------------------------------------------------------------------------------
103
104
}
// FIX8
105
106
#endif // FIX8_CONSOLEMENU_HPP_
FIX8::ConsoleMenu::GetString
F8API f8String & GetString(tty_save_state &tty, f8String &to) const
Definition:
consolemenu.cpp:322
FIX8::ConsoleMenu::~ConsoleMenu
virtual ~ConsoleMenu()
Dtor.
Definition:
consolemenu.hpp:66
FIX8::BaseMsgEntry
Message instantiation table entry.
Definition:
message.hpp:192
FIX8::_pair
Pair abstraction for use with GeneratedTable.
Definition:
f8types.hpp:69
FIX8::ConsoleMenu::_lpp
int _lpp
Definition:
consolemenu.hpp:53
FIX8::tty_save_state
Definition:
f8utils.hpp:1168
FIX8::ConsoleMenu::RemoveMsg
F8API Message * RemoveMsg(tty_save_state &tty, MsgList &lst) const
Definition:
consolemenu.cpp:384
FIX8::ConsoleMenu::CreateMsgsFrom
F8API int CreateMsgsFrom(tty_save_state &tty, MsgList &lst, const MsgList &from) const
Definition:
consolemenu.cpp:279
FIX8::ConsoleMenu::_os
std::ostream & _os
Definition:
consolemenu.hpp:52
FIX8::ConsoleMenu::EditMsg
F8API void EditMsg(tty_save_state &tty, const FieldTable::Pair *fld, Message *msg) const
Definition:
consolemenu.cpp:332
FIX8::MsgList
std::deque< FIX8::Message * > MsgList
Definition:
consolemenu.hpp:44
FIX8::ConsoleMenu::SelectRealm
virtual F8API int SelectRealm(const unsigned short fnum, const RealmBase *rb) const
Definition:
consolemenu.cpp:166
FIX8::RealmBase
Domain range/set static metadata base class.
Definition:
field.hpp:58
FIX8::ConsoleMenu::EditMsgs
virtual F8API int EditMsgs(tty_save_state &tty, MsgList &lst) const
Definition:
consolemenu.cpp:367
FIX8::ConsoleMenu::_fld_prompt
static const f8String _fld_prompt
Definition:
consolemenu.hpp:54
FIX8::TEX::ctx
const F8MetaCntx & ctx()
Compiler generated metadata object, accessed through this function.
Definition:
Myfix_classes.cpp:424
F8API
#define F8API
Definition:
f8dll.h:60
FIX8::ConsoleMenu
Console test harness menu.
Definition:
consolemenu.hpp:48
FIX8::ConsoleMenu::_ctx
const F8MetaCntx & _ctx
Definition:
consolemenu.hpp:50
FIX8::Message
A complete Fix message with header, body and trailer.
Definition:
message.hpp:1058
FIX8::ConsoleMenu::_is
std::istream & _is
Definition:
consolemenu.hpp:51
FIX8::ConsoleMenu::SelectFromMsg
F8API Message * SelectFromMsg(const MsgList &lst) const
Definition:
consolemenu.cpp:218
FIX8::ConsoleMenu::CreateMsgs
virtual F8API int CreateMsgs(tty_save_state &tty, MsgList &lst) const
Definition:
consolemenu.cpp:302
FIX8::ConsoleMenu::get_key
char get_key(const f8String &prompt=std::string(), bool echo=false) const
Definition:
consolemenu.hpp:84
FIX8::ConsoleMenu::set_lpp
void set_lpp(int lpp)
Definition:
consolemenu.hpp:81
FIX8::ConsoleMenu::ConsoleMenu
ConsoleMenu(const F8MetaCntx &ctx, std::istream &is=std::cin, std::ostream &os=std::cout, int lpp=20)
Definition:
consolemenu.hpp:62
FIX8
Definition:
configuration.hpp:47
FIX8::ConsoleMenu::get_yn
bool get_yn(const f8String &prompt, bool echo=false) const
Definition:
consolemenu.hpp:83
FIX8::ConsoleMenu::SelectField
virtual F8API const FieldTable::Pair * SelectField(const Message *msg, int groupid=0) const
Definition:
consolemenu.cpp:101
FIX8::ConsoleMenu::DeleteAllMsgs
virtual F8API int DeleteAllMsgs(tty_save_state &tty, MsgList &lst) const
Definition:
consolemenu.cpp:408
FIX8::ConsoleMenu::get_lpp
int get_lpp() const
Definition:
consolemenu.hpp:80
FIX8::F8MetaCntx
Static metadata context class - one per FIX xml schema.
Definition:
message.hpp:210
FIX8::ConsoleMenu::SelectMsg
virtual F8API const BaseMsgEntry * SelectMsg() const
Definition:
consolemenu.cpp:50
FIX8::ConsoleMenu::_opt_keys
static const f8String _opt_keys
Definition:
consolemenu.hpp:54
FIX8::f8String
std::string f8String
Definition:
f8types.hpp:47
FIX8::ConsoleMenu::DeleteMsgs
virtual F8API int DeleteMsgs(tty_save_state &tty, MsgList &lst) const
Definition:
consolemenu.cpp:420
fix8
documentation generated on Fri Sep 16 2016 11:53:03. Copyright © 2010-16,
The Fix8 Team.
All rights reserved.