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
ed570b9f
Commit
ed570b9f
authored
Oct 19, 2009
by
Jesse Beder
Browse files
Added default constructor to Parser, and cleaned it up a bit
parent
59b0e986
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
include/parser.h
include/parser.h
+7
-9
src/parser.cpp
src/parser.cpp
+8
-6
No files found.
include/parser.h
View file @
ed570b9f
...
@@ -4,21 +4,24 @@
...
@@ -4,21 +4,24 @@
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#include "node.h"
#include "parserstate.h"
#include "noncopyable.h"
#include <ios>
#include <ios>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <map>
#include <map>
#include "node.h"
#include <memory>
#include "parserstate.h"
namespace
YAML
namespace
YAML
{
{
class
Scanner
;
class
Scanner
;
struct
Token
;
struct
Token
;
class
Parser
class
Parser
:
private
noncopyable
{
{
public:
public:
Parser
();
Parser
(
std
::
istream
&
in
);
Parser
(
std
::
istream
&
in
);
~
Parser
();
~
Parser
();
...
@@ -35,12 +38,7 @@ namespace YAML
...
@@ -35,12 +38,7 @@ namespace YAML
void
HandleTagDirective
(
Token
*
pToken
);
void
HandleTagDirective
(
Token
*
pToken
);
private:
private:
// can't copy this
std
::
auto_ptr
<
Scanner
>
m_pScanner
;
Parser
(
const
Parser
&
)
{}
Parser
&
operator
=
(
const
Parser
&
)
{
return
*
this
;
}
private:
Scanner
*
m_pScanner
;
ParserState
m_state
;
ParserState
m_state
;
};
};
}
}
...
...
src/parser.cpp
View file @
ed570b9f
...
@@ -8,25 +8,27 @@
...
@@ -8,25 +8,27 @@
namespace
YAML
namespace
YAML
{
{
Parser
::
Parser
(
std
::
istream
&
in
)
:
m_pScanner
(
0
)
Parser
::
Parser
()
{
}
Parser
::
Parser
(
std
::
istream
&
in
)
{
{
Load
(
in
);
Load
(
in
);
}
}
Parser
::~
Parser
()
Parser
::~
Parser
()
{
{
delete
m_pScanner
;
}
}
Parser
::
operator
bool
()
const
Parser
::
operator
bool
()
const
{
{
return
!
m_pScanner
->
empty
();
return
m_pScanner
.
get
()
&&
!
m_pScanner
->
empty
();
}
}
void
Parser
::
Load
(
std
::
istream
&
in
)
void
Parser
::
Load
(
std
::
istream
&
in
)
{
{
delete
m_pScanner
;
m_pScanner
.
reset
(
new
Scanner
(
in
));
m_pScanner
=
new
Scanner
(
in
);
m_state
.
Reset
();
m_state
.
Reset
();
}
}
...
@@ -50,7 +52,7 @@ namespace YAML
...
@@ -50,7 +52,7 @@ namespace YAML
m_pScanner
->
pop
();
m_pScanner
->
pop
();
// now parse our root node
// now parse our root node
document
.
Parse
(
m_pScanner
,
m_state
);
document
.
Parse
(
m_pScanner
.
get
()
,
m_state
);
// and finally eat any doc ends we see
// and finally eat any doc ends we see
while
(
!
m_pScanner
->
empty
()
&&
m_pScanner
->
peek
().
type
==
Token
::
DOC_END
)
while
(
!
m_pScanner
->
empty
()
&&
m_pScanner
->
peek
().
type
==
Token
::
DOC_END
)
...
...
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