Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
1f4d8ee3
Commit
1f4d8ee3
authored
May 19, 2012
by
Jesse Beder
Browse files
Removed parse
parent
06cb65c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
67 deletions
+0
-67
util/CMakeLists.txt
util/CMakeLists.txt
+0
-2
util/parse.cpp
util/parse.cpp
+0
-65
No files found.
util/CMakeLists.txt
View file @
1f4d8ee3
add_executable
(
parse parse.cpp
)
target_link_libraries
(
parse yaml-cpp
)
util/parse.cpp
deleted
100644 → 0
View file @
06cb65c6
#include "yaml-cpp/yaml.h"
#include "yaml-cpp/eventhandler.h"
#include <fstream>
#include <iostream>
#include <vector>
struct
Params
{
bool
hasFile
;
std
::
string
fileName
;
};
Params
ParseArgs
(
int
argc
,
char
**
argv
)
{
Params
p
;
std
::
vector
<
std
::
string
>
args
(
argv
+
1
,
argv
+
argc
);
return
p
;
}
class
NullEventHandler
:
public
YAML
::
EventHandler
{
public:
virtual
void
OnDocumentStart
(
const
YAML
::
Mark
&
)
{}
virtual
void
OnDocumentEnd
()
{}
virtual
void
OnNull
(
const
YAML
::
Mark
&
,
YAML
::
anchor_t
)
{}
virtual
void
OnAlias
(
const
YAML
::
Mark
&
,
YAML
::
anchor_t
)
{}
virtual
void
OnScalar
(
const
YAML
::
Mark
&
,
const
std
::
string
&
,
YAML
::
anchor_t
,
const
std
::
string
&
)
{}
virtual
void
OnSequenceStart
(
const
YAML
::
Mark
&
,
const
std
::
string
&
,
YAML
::
anchor_t
)
{}
virtual
void
OnSequenceEnd
()
{}
virtual
void
OnMapStart
(
const
YAML
::
Mark
&
,
const
std
::
string
&
,
YAML
::
anchor_t
)
{}
virtual
void
OnMapEnd
()
{}
};
void
parse
(
std
::
istream
&
input
)
{
try
{
YAML
::
Parser
parser
(
input
);
YAML
::
Node
doc
;
while
(
parser
.
GetNextDocument
(
doc
))
{
YAML
::
Emitter
emitter
;
emitter
<<
doc
;
std
::
cout
<<
emitter
.
c_str
()
<<
"
\n
"
;
}
}
catch
(
const
YAML
::
Exception
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
"
\n
"
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
Params
p
=
ParseArgs
(
argc
,
argv
);
if
(
argc
>
1
)
{
std
::
ifstream
fin
;
fin
.
open
(
argv
[
1
]);
parse
(
fin
);
}
else
{
parse
(
std
::
cin
);
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment