Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
3392ab98
Commit
3392ab98
authored
May 12, 2016
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update doc, formatting for parse.h.
parent
6c569e58
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
6 deletions
+58
-6
include/yaml-cpp/node/parse.h
+49
-1
src/parse.cpp
+9
-5
No files found.
include/yaml-cpp/node/parse.h
View file @
3392ab98
...
@@ -16,15 +16,63 @@
...
@@ -16,15 +16,63 @@
namespace
YAML
{
namespace
YAML
{
class
Node
;
class
Node
;
/**
* Loads the input string as a single YAML document.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
Node
Load
(
const
std
::
string
&
input
);
YAML_CPP_API
Node
Load
(
const
std
::
string
&
input
);
/**
* Loads the input string as a single YAML document.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
Node
Load
(
const
char
*
input
);
YAML_CPP_API
Node
Load
(
const
char
*
input
);
/**
* Loads the input stream as a single YAML document.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
Node
Load
(
std
::
istream
&
input
);
YAML_CPP_API
Node
Load
(
std
::
istream
&
input
);
/**
* Loads the input file as a single YAML document.
*
* @throws {@link ParserException} if it is malformed.
* @throws {@link BadFile} if the file cannot be loaded.
*/
YAML_CPP_API
Node
LoadFile
(
const
std
::
string
&
filename
);
YAML_CPP_API
Node
LoadFile
(
const
std
::
string
&
filename
);
/**
* Loads the input string as a list of YAML documents.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
const
std
::
string
&
input
);
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
const
std
::
string
&
input
);
/**
* Loads the input string as a list of YAML documents.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
const
char
*
input
);
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
const
char
*
input
);
/**
* Loads the input stream as a list of YAML documents.
*
* @throws {@link ParserException} if it is malformed.
*/
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
std
::
istream
&
input
);
YAML_CPP_API
std
::
vector
<
Node
>
LoadAll
(
std
::
istream
&
input
);
/**
* Loads the input file as a list of YAML documents.
*
* @throws {@link ParserException} if it is malformed.
* @throws {@link BadFile} if the file cannot be loaded.
*/
YAML_CPP_API
std
::
vector
<
Node
>
LoadAllFromFile
(
const
std
::
string
&
filename
);
YAML_CPP_API
std
::
vector
<
Node
>
LoadAllFromFile
(
const
std
::
string
&
filename
);
}
}
// namespace YAML
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/parse.cpp
View file @
3392ab98
...
@@ -22,16 +22,18 @@ Node Load(const char* input) {
...
@@ -22,16 +22,18 @@ Node Load(const char* input) {
Node
Load
(
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
))
{
return
Node
();
return
Node
();
}
return
builder
.
Root
();
return
builder
.
Root
();
}
}
Node
LoadFile
(
const
std
::
string
&
filename
)
{
Node
LoadFile
(
const
std
::
string
&
filename
)
{
std
::
ifstream
fin
(
filename
.
c_str
());
std
::
ifstream
fin
(
filename
.
c_str
());
if
(
!
fin
)
if
(
!
fin
)
{
throw
BadFile
();
throw
BadFile
();
}
return
Load
(
fin
);
return
Load
(
fin
);
}
}
...
@@ -51,8 +53,9 @@ std::vector<Node> LoadAll(std::istream& input) {
...
@@ -51,8 +53,9 @@ std::vector<Node> LoadAll(std::istream& input) {
Parser
parser
(
input
);
Parser
parser
(
input
);
while
(
1
)
{
while
(
1
)
{
NodeBuilder
builder
;
NodeBuilder
builder
;
if
(
!
parser
.
HandleNextDocument
(
builder
))
if
(
!
parser
.
HandleNextDocument
(
builder
))
{
break
;
break
;
}
docs
.
push_back
(
builder
.
Root
());
docs
.
push_back
(
builder
.
Root
());
}
}
...
@@ -61,8 +64,9 @@ std::vector<Node> LoadAll(std::istream& input) {
...
@@ -61,8 +64,9 @@ std::vector<Node> LoadAll(std::istream& input) {
std
::
vector
<
Node
>
LoadAllFromFile
(
const
std
::
string
&
filename
)
{
std
::
vector
<
Node
>
LoadAllFromFile
(
const
std
::
string
&
filename
)
{
std
::
ifstream
fin
(
filename
.
c_str
());
std
::
ifstream
fin
(
filename
.
c_str
());
if
(
!
fin
)
if
(
!
fin
)
{
throw
BadFile
();
throw
BadFile
();
}
return
LoadAll
(
fin
);
return
LoadAll
(
fin
);
}
}
}
}
// namespace YAML
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