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
e3d5ec18
Commit
e3d5ec18
authored
Sep 13, 2011
by
Jesse Beder
Browse files
Switched YAML::Parse to YAML::Load, and added LoadAll
parent
5be19ccb
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
117 deletions
+146
-117
include/yaml-cpp/node/parse.h
include/yaml-cpp/node/parse.h
+9
-4
src/node/parse.cpp
src/node/parse.cpp
+29
-5
test/new-api/spectests.cpp
test/new-api/spectests.cpp
+107
-107
util/parse.cpp
util/parse.cpp
+1
-1
No files found.
include/yaml-cpp/node/parse.h
View file @
e3d5ec18
...
@@ -5,16 +5,21 @@
...
@@ -5,16 +5,21 @@
#pragma once
#pragma once
#endif
#endif
#include <string>
#include <iosfwd>
#include <iosfwd>
#include <string>
#include <vector>
namespace
YAML
namespace
YAML
{
{
class
Node
;
class
Node
;
Node
Parse
(
const
std
::
string
&
input
);
Node
Load
(
const
std
::
string
&
input
);
Node
Parse
(
const
char
*
input
);
Node
Load
(
const
char
*
input
);
Node
Parse
(
std
::
istream
&
input
);
Node
Load
(
std
::
istream
&
input
);
std
::
vector
<
Node
>
LoadAll
(
const
std
::
string
&
input
);
std
::
vector
<
Node
>
LoadAll
(
const
char
*
input
);
std
::
vector
<
Node
>
LoadAll
(
std
::
istream
&
input
);
}
}
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
...
...
src/node/parse.cpp
View file @
e3d5ec18
...
@@ -8,17 +8,17 @@
...
@@ -8,17 +8,17 @@
namespace
YAML
namespace
YAML
{
{
Node
Parse
(
const
std
::
string
&
input
)
{
Node
Load
(
const
std
::
string
&
input
)
{
std
::
stringstream
stream
(
input
);
std
::
stringstream
stream
(
input
);
return
Parse
(
stream
);
return
Load
(
stream
);
}
}
Node
Parse
(
const
char
*
input
)
{
Node
Load
(
const
char
*
input
)
{
std
::
stringstream
stream
(
input
);
std
::
stringstream
stream
(
input
);
return
Parse
(
stream
);
return
Load
(
stream
);
}
}
Node
Parse
(
std
::
istream
&
input
)
{
Node
Load
(
std
::
istream
&
input
)
{
Parser
parser
(
input
);
Parser
parser
(
input
);
NodeBuilder
builder
;
NodeBuilder
builder
;
if
(
!
parser
.
HandleNextDocument
(
builder
))
if
(
!
parser
.
HandleNextDocument
(
builder
))
...
@@ -26,4 +26,28 @@ namespace YAML
...
@@ -26,4 +26,28 @@ namespace YAML
return
builder
.
Root
();
return
builder
.
Root
();
}
}
std
::
vector
<
Node
>
LoadAll
(
const
std
::
string
&
input
)
{
std
::
stringstream
stream
(
input
);
return
LoadAll
(
stream
);
}
std
::
vector
<
Node
>
LoadAll
(
const
char
*
input
)
{
std
::
stringstream
stream
(
input
);
return
LoadAll
(
stream
);
}
std
::
vector
<
Node
>
LoadAll
(
std
::
istream
&
input
)
{
std
::
vector
<
Node
>
docs
;
Parser
parser
(
input
);
while
(
1
)
{
NodeBuilder
builder
;
if
(
!
parser
.
HandleNextDocument
(
builder
))
break
;
docs
.
push_back
(
builder
.
Root
());
}
return
docs
;
}
}
}
test/new-api/spectests.cpp
View file @
e3d5ec18
This diff is collapsed.
Click to expand it.
util/parse.cpp
View file @
e3d5ec18
...
@@ -46,7 +46,7 @@ void parse(std::istream& input)
...
@@ -46,7 +46,7 @@ void parse(std::istream& input)
std
::
cout
<<
emitter
.
c_str
()
<<
"
\n
"
;
std
::
cout
<<
emitter
.
c_str
()
<<
"
\n
"
;
}
}
#else
#else
YAML
::
Node
doc
=
YAML
::
Parse
(
input
);
YAML
::
Node
doc
=
YAML
::
Load
(
input
);
std
::
cout
<<
doc
<<
"
\n
"
;
std
::
cout
<<
doc
<<
"
\n
"
;
#endif
#endif
}
catch
(
const
YAML
::
Exception
&
e
)
{
}
catch
(
const
YAML
::
Exception
&
e
)
{
...
...
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