summaryrefslogtreecommitdiff
path: root/cli/runtime-inline.cxx
blob: 9c33c2e195e8976b9f88a7a914d4a039d914182b (plain)
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
// file      : cli/runtime-inline.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#include "runtime-inline.hxx"

using namespace std;

void
generate_runtime_inline (context& ctx)
{
  ostream& os (ctx.os);
  string const& inl (ctx.inl);

  os << "namespace cli"
     << "{";

  os << "// unknown_mode" << endl
     << "//" << endl;

  os << inl << "unknown_mode::" << endl
     << "unknown_mode (value v)" << endl
     << ": v_ (v)"
     << "{"
     << "}";

  os << "// exception" << endl
     << "//" << endl;

  os << inl << "std::ostream&" << endl
     << "operator<< (std::ostream& os, const exception& e)"
     << "{"
     << "e.print (os);"
     << "return os;"
     << "}";

  os << "// unknown_option" << endl
     << "//" << endl;

  os << inl << "unknown_option::" << endl
     << "unknown_option (const std::string& option)" << endl
     << ": option_ (option)"
     << "{"
     << "}";

  os << inl << "const std::string& unknown_option::" << endl
     << "option () const"
     << "{"
     << "return option_;"
     << "}";

  os << "// unknown_argument" << endl
     << "//" << endl;

  os << inl << "unknown_argument::" << endl
     << "unknown_argument (const std::string& argument)" << endl
     << ": argument_ (argument)"
     << "{"
     << "}";

  os << inl << "const std::string& unknown_argument::" << endl
     << "argument () const"
     << "{"
     << "return argument_;"
     << "}";

  os << "// missing_value" << endl
     << "//" << endl;

  os << inl << "missing_value::" << endl
     << "missing_value (const std::string& option)" << endl
     << ": option_ (option)"
     << "{"
     << "}";

  os << inl << "const std::string& missing_value::" << endl
     << "option () const"
     << "{"
     << "return option_;"
     << "}";

  os << "// invalid_value" << endl
     << "//" << endl;

  os << inl << "invalid_value::" << endl
     << "invalid_value (const std::string& option," << endl
     << "const std::string& value)" << endl
     << ": option_ (option),"
     << "  value_ (value)"
     << "{"
     << "}";

  os << inl << "const std::string& invalid_value::" << endl
     << "option () const"
     << "{"
     << "return option_;"
     << "}";

  os << inl << "const std::string& invalid_value::" << endl
     << "value () const"
     << "{"
     << "return value_;"
     << "}";

  os << "}"; // namespace cli
}