|
Revision 691, 0.8 kB
(checked in by tapted, 2 years ago)
|
|
Guarantee initialisation, allow vars to be configured at declaration, add _getvalue
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
author date id revision url Rev Revision
|
| Line | |
|---|
| 1 | #include "rconfig.h" |
|---|
| 2 | #include "editlinewrap.h" |
|---|
| 3 | |
|---|
| 4 | #include <iostream> |
|---|
| 5 | using namespace std; |
|---|
| 6 | |
|---|
| 7 | namespace { |
|---|
| 8 | int RCFILE_CONFIGVAR(SOMEINT, 5); |
|---|
| 9 | double RCFILE_CONFIGVAR(SOMEDBL, 1.33); |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | int main() { |
|---|
| 13 | Editline el(">>> "); |
|---|
| 14 | RConfig::rcfile_tell("PROMPT", el.default_prompt); |
|---|
| 15 | |
|---|
| 16 | RConfig::rcfile_parse("config"); |
|---|
| 17 | |
|---|
| 18 | { |
|---|
| 19 | std::vector<std::string> vars; |
|---|
| 20 | RConfig::rcfile_getnames(vars); |
|---|
| 21 | el.addCompletions(vars.begin(), vars.end()); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | bool eof = false; |
|---|
| 25 | std::string line; |
|---|
| 26 | std::string val; |
|---|
| 27 | while ((line = el.readLine(eof)) != "exit" && !eof) { |
|---|
| 28 | if (!RConfig::rcfile_parseline(line)) { |
|---|
| 29 | if (RConfig::rcfile_getvalue(val, line)) { |
|---|
| 30 | cout << line << " = " << val << endl; |
|---|
| 31 | } else { |
|---|
| 32 | cout << "Couldn't parse " << line << endl; |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | } |
|---|