Loading...
Searching...
No Matches
src
drain
prog
CommandSequence.h
1
/*
2
3
MIT License
4
5
Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software and associated documentation files (the "Software"), to deal
9
in the Software without restriction, including without limitation the rights
10
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the Software is
12
furnished to do so, subject to the following conditions:
13
14
The above copyright notice and this permission notice shall be included in all
15
copies or substantial portions of the Software.
16
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
SOFTWARE.
24
25
*/
26
/*
27
Part of Rack development has been done in the BALTRAD projects part-financed
28
by the European Union (European Regional Development Fund and European
29
Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30
*/
31
32
// New design (2020)
33
34
#ifndef DRAIN_CMD_SEQ_H_
35
#define DRAIN_CMD_SEQ_H_
36
37
#include <iostream>
38
#include <list>
39
40
#include <drain/Sprinter.h>
41
42
43
44
namespace
drain
{
45
47
template
<
class
T>
48
class
CommandSequence
:
public
std::list<T> {
49
50
public
:
51
52
typedef
T entry_t;
53
54
typedef
std::list<T> list_t;
55
56
// virtual consider
57
// typename list_t::value_type & add(key, cmd) = 0;
58
60
inline
61
operator
bool(){
return
!this->empty(); };
62
63
};
64
65
template
<
class
T>
66
inline
67
std::ostream & operator<<(std::ostream & ostr,
const
CommandSequence<T>
& commands){
68
76
static
const
SprinterLayout
layout(
"\n"
,
"{,}"
,
"="
,
""
);
77
78
Sprinter::sequenceToStream
(ostr, commands, layout);
79
return
ostr;
80
}
81
82
83
84
85
class
Script
:
public
CommandSequence
<std::pair<std::string,std::string> > {
86
87
public
:
88
89
inline
90
typename
list_t::value_type & add(
const
std::string & key,
const
std::string & params=
""
){
91
//typename Script::entry_t & Script::add(const std::string & cmd, const std::string & params){
92
this->push_back(
typename
list_t::value_type(key, params));
93
return
back();
94
}
95
96
};
97
98
99
100
101
102
}
/* namespace drain */
103
104
#endif
// CMD_SEQ
drain::CommandSequence
A base class for Script and Program.
Definition
CommandSequence.h:48
drain::Script
Definition
CommandSequence.h:85
drain::Sprinter::sequenceToStream
static std::ostream & sequenceToStream(std::ostream &ostr, const T &x, const SprinterLayout &layout)
Convenience: if sequence type (array, list, set, map) not given, assume array.
Definition
Sprinter.h:325
drain
Definition
DataSelector.cpp:1277
drain::SprinterLayout
Definition
Sprinter.h:137
Generated by
1.9.8