diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-05 00:41:22 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-05 00:41:22 -0700 |
commit | de83196633b28f06bb8c08ddf5780cc8049703f4 (patch) | |
tree | 25e1434132496a68112f4e0fe52d82fcb2cbc91c /src/options.cpp | |
parent | ef56ac3105dbd72cc5989edef9bbbb3fedfe6449 (diff) | |
download | stage-de83196633b28f06bb8c08ddf5780cc8049703f4.tar.gz stage-de83196633b28f06bb8c08ddf5780cc8049703f4.tar.bz2 stage-de83196633b28f06bb8c08ddf5780cc8049703f4.tar.xz stage-de83196633b28f06bb8c08ddf5780cc8049703f4.zip |
Interface plugin basics. SML system parser.
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp index f5fb127..1cc76ce 100644 --- a/src/options.cpp +++ b/src/options.cpp | |||
@@ -2,8 +2,11 @@ | |||
2 | #include "version.h" | 2 | #include "version.h" |
3 | #include "game.h" | 3 | #include "game.h" |
4 | 4 | ||
5 | #include "smlnode.h" | ||
6 | |||
5 | #include <stdlib.h> | 7 | #include <stdlib.h> |
6 | 8 | ||
9 | #include <bu/file.h> | ||
7 | #include <bu/optparser.h> | 10 | #include <bu/optparser.h> |
8 | #include <bu/sio.h> | 11 | #include <bu/sio.h> |
9 | 12 | ||
@@ -26,6 +29,8 @@ void Options::parse( int argc, char *argv[] ) | |||
26 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + | 29 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + |
27 | " [options] <filename>\n"); | 30 | " [options] <filename>\n"); |
28 | 31 | ||
32 | opt.addOption( Bu::slot( this, &Options::smlTest ), "sml-test", | ||
33 | "Test SML parser." ); | ||
29 | opt.addOption( Bu::slot( this, &Options::version ), "version", | 34 | opt.addOption( Bu::slot( this, &Options::version ), "version", |
30 | "Show full version info." ); | 35 | "Show full version info." ); |
31 | opt.addOption( Bu::slot( this, &Options::builtins ), "builtins", | 36 | opt.addOption( Bu::slot( this, &Options::builtins ), "builtins", |
@@ -62,6 +67,25 @@ int Options::builtins( Bu::StrArray aArgs ) | |||
62 | return 0; | 67 | return 0; |
63 | } | 68 | } |
64 | 69 | ||
70 | int Options::smlTest( Bu::Array<Bu::String> aArgs ) | ||
71 | { | ||
72 | Bu::String sContent; | ||
73 | Bu::File fIn( aArgs[1], Bu::File::Read ); | ||
74 | while( !fIn.isEos() ) | ||
75 | { | ||
76 | char buf[4096]; | ||
77 | sContent.append( buf, fIn.read( buf, 4096 ) ); | ||
78 | } | ||
79 | fIn.close(); | ||
80 | |||
81 | SmlNode *pRoot = SmlNode::parse( sContent ); | ||
82 | sio << *pRoot << sio.nl; | ||
83 | delete pRoot; | ||
84 | |||
85 | exit( 0 ); | ||
86 | return 0; | ||
87 | } | ||
88 | |||
65 | int Options::nonOption( Bu::Array<Bu::String> aArgs ) | 89 | int Options::nonOption( Bu::Array<Bu::String> aArgs ) |
66 | { | 90 | { |
67 | sFile = aArgs[0]; | 91 | sFile = aArgs[0]; |