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
c1966ba3
Commit
c1966ba3
authored
Jun 30, 2008
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the stream member functions get() and eat().
parent
852e5b63
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
74 deletions
+143
-74
exp.cpp
+3
-3
scanner.cpp
+3
-3
scanner.h
+0
-1
scanscalar.cpp
+6
-6
scantoken.cpp
+23
-23
stream.cpp
+8
-8
stream.h
+4
-4
test.yaml
+96
-26
No files found.
exp.cpp
View file @
c1966ba3
...
...
@@ -39,7 +39,7 @@ namespace YAML
// grab string
std
::
string
str
;
for
(
int
i
=
0
;
i
<
codeLength
;
i
++
)
str
+=
in
.
GetChar
();
str
+=
in
.
get
();
// get the value
unsigned
value
=
ParseHex
(
str
);
...
...
@@ -67,10 +67,10 @@ namespace YAML
std
::
string
Escape
(
Stream
&
in
)
{
// eat slash
char
escape
=
in
.
GetChar
();
char
escape
=
in
.
get
();
// switch on escape character
char
ch
=
in
.
GetChar
();
char
ch
=
in
.
get
();
// first do single quote, since it's easier
if
(
escape
==
'\''
&&
ch
==
'\''
)
...
...
scanner.cpp
View file @
c1966ba3
...
...
@@ -153,13 +153,13 @@ namespace YAML
while
(
1
)
{
// first eat whitespace
while
(
IsWhitespaceToBeEaten
(
INPUT
.
peek
()))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// then eat a comment
if
(
Exp
::
Comment
.
Matches
(
INPUT
))
{
// eat until line break
while
(
INPUT
&&
!
Exp
::
Break
.
Matches
(
INPUT
))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
}
// if it's NOT a line break, then we're done!
...
...
@@ -168,7 +168,7 @@ namespace YAML
// otherwise, let's eat the line break and keep going
int
n
=
Exp
::
Break
.
Match
(
INPUT
);
INPUT
.
E
at
(
n
);
INPUT
.
e
at
(
n
);
// oh yeah, and let's get rid of that simple key
VerifySimpleKey
();
...
...
scanner.h
View file @
c1966ba3
...
...
@@ -5,7 +5,6 @@
#include <queue>
#include <stack>
#include <set>
#include "regex.h"
#include "stream.h"
namespace
YAML
...
...
scanscalar.cpp
View file @
c1966ba3
...
...
@@ -43,7 +43,7 @@ namespace YAML
// escaped newline? (only if we're escaping on slash)
if
(
params
.
escape
==
'\\'
&&
Exp
::
EscBreak
.
Matches
(
INPUT
))
{
int
n
=
Exp
::
EscBreak
.
Match
(
INPUT
);
INPUT
.
E
at
(
n
);
INPUT
.
e
at
(
n
);
continue
;
}
...
...
@@ -54,7 +54,7 @@ namespace YAML
}
// otherwise, just add the damn character
scalar
+=
INPUT
.
GetChar
();
scalar
+=
INPUT
.
get
();
}
// eof? if we're looking to eat something, then we throw
...
...
@@ -72,21 +72,21 @@ namespace YAML
int
n
=
params
.
end
.
Match
(
INPUT
);
if
(
n
>=
0
)
{
if
(
params
.
eatEnd
)
INPUT
.
E
at
(
n
);
INPUT
.
e
at
(
n
);
break
;
}
// ********************************
// Phase #2: eat line ending
n
=
Exp
::
Break
.
Match
(
INPUT
);
INPUT
.
E
at
(
n
);
INPUT
.
e
at
(
n
);
// ********************************
// Phase #3: scan initial spaces
// first the required indentation
while
(
INPUT
.
peek
()
==
' '
&&
(
INPUT
.
column
<
params
.
indent
||
(
params
.
detectIndent
&&
!
foundNonEmptyLine
)))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// update indent if we're auto-detecting
if
(
params
.
detectIndent
&&
!
foundNonEmptyLine
)
...
...
@@ -101,7 +101,7 @@ namespace YAML
if
(
!
params
.
eatLeadingWhitespace
)
break
;
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
}
// was this an empty line?
...
...
scantoken.cpp
View file @
c1966ba3
...
...
@@ -23,17 +23,17 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat indicator
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// read name
while
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
BlankOrBreak
.
Matches
(
INPUT
))
name
+=
INPUT
.
GetChar
();
name
+=
INPUT
.
get
();
// read parameters
while
(
1
)
{
// first get rid of whitespace
while
(
Exp
::
Blank
.
Matches
(
INPUT
))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// break on newline or comment
if
(
INPUT
.
peek
()
==
EOF
||
Exp
::
Break
.
Matches
(
INPUT
)
||
Exp
::
Comment
.
Matches
(
INPUT
))
...
...
@@ -42,7 +42,7 @@ namespace YAML
// now read parameter
std
::
string
param
;
while
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
BlankOrBreak
.
Matches
(
INPUT
))
param
+=
INPUT
.
GetChar
();
param
+=
INPUT
.
get
();
params
.
push_back
(
param
);
}
...
...
@@ -61,7 +61,7 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat
INPUT
.
E
at
(
3
);
INPUT
.
e
at
(
3
);
m_tokens
.
push
(
new
Token
(
TT_DOC_START
));
}
...
...
@@ -73,7 +73,7 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat
INPUT
.
E
at
(
3
);
INPUT
.
e
at
(
3
);
m_tokens
.
push
(
new
Token
(
TT_DOC_END
));
}
...
...
@@ -86,7 +86,7 @@ namespace YAML
m_simpleKeyAllowed
=
true
;
// eat
char
ch
=
INPUT
.
GetChar
();
char
ch
=
INPUT
.
get
();
TOKEN_TYPE
type
=
(
ch
==
Keys
::
FlowSeqStart
?
TT_FLOW_SEQ_START
:
TT_FLOW_MAP_START
);
m_tokens
.
push
(
new
Token
(
type
));
}
...
...
@@ -101,7 +101,7 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat
char
ch
=
INPUT
.
GetChar
();
char
ch
=
INPUT
.
get
();
TOKEN_TYPE
type
=
(
ch
==
Keys
::
FlowSeqEnd
?
TT_FLOW_SEQ_END
:
TT_FLOW_MAP_END
);
m_tokens
.
push
(
new
Token
(
type
));
}
...
...
@@ -112,7 +112,7 @@ namespace YAML
m_simpleKeyAllowed
=
true
;
// eat
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
m_tokens
.
push
(
new
Token
(
TT_FLOW_ENTRY
));
}
...
...
@@ -131,7 +131,7 @@ namespace YAML
m_simpleKeyAllowed
=
true
;
// eat
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
m_tokens
.
push
(
new
Token
(
TT_BLOCK_ENTRY
));
}
...
...
@@ -153,7 +153,7 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
m_tokens
.
push
(
new
Token
(
TT_KEY
));
}
...
...
@@ -181,7 +181,7 @@ namespace YAML
}
// eat
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
m_tokens
.
push
(
new
Token
(
TT_VALUE
));
}
...
...
@@ -197,12 +197,12 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat the indicator
char
indicator
=
INPUT
.
GetChar
();
char
indicator
=
INPUT
.
get
();
alias
=
(
indicator
==
Keys
::
Alias
);
// now eat the content
while
(
Exp
::
AlphaNumeric
.
Matches
(
INPUT
))
tag
+=
INPUT
.
GetChar
();
tag
+=
INPUT
.
get
();
// we need to have read SOMETHING!
if
(
tag
.
empty
())
...
...
@@ -229,20 +229,20 @@ namespace YAML
m_simpleKeyAllowed
=
false
;
// eat the indicator
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// read the handle
while
(
INPUT
.
peek
()
!=
EOF
&&
INPUT
.
peek
()
!=
Keys
::
Tag
&&
!
Exp
::
BlankOrBreak
.
Matches
(
INPUT
))
handle
+=
INPUT
.
GetChar
();
handle
+=
INPUT
.
get
();
// is there a suffix?
if
(
INPUT
.
peek
()
==
Keys
::
Tag
)
{
// eat the indicator
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// then read it
while
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
BlankOrBreak
.
Matches
(
INPUT
))
suffix
+=
INPUT
.
GetChar
();
suffix
+=
INPUT
.
get
();
}
Token
*
pToken
=
new
Token
(
TT_TAG
);
...
...
@@ -293,7 +293,7 @@ namespace YAML
std
::
string
scalar
;
// eat single or double quote
char
quote
=
INPUT
.
GetChar
();
char
quote
=
INPUT
.
get
();
bool
single
=
(
quote
==
'\''
);
// setup the scanning parameters
...
...
@@ -333,13 +333,13 @@ namespace YAML
params
.
detectIndent
=
true
;
// eat block indicator ('|' or '>')
char
indicator
=
INPUT
.
GetChar
();
char
indicator
=
INPUT
.
get
();
params
.
fold
=
(
indicator
==
Keys
::
FoldedScalar
);
// eat chomping/indentation indicators
int
n
=
Exp
::
Chomp
.
Match
(
INPUT
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
char
ch
=
INPUT
.
GetChar
();
char
ch
=
INPUT
.
get
();
if
(
ch
==
'+'
)
params
.
chomp
=
KEEP
;
else
if
(
ch
==
'-'
)
...
...
@@ -355,12 +355,12 @@ namespace YAML
// now eat whitespace
while
(
Exp
::
Blank
.
Matches
(
INPUT
))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// and comments to the end of the line
if
(
Exp
::
Comment
.
Matches
(
INPUT
))
while
(
INPUT
&&
!
Exp
::
Break
.
Matches
(
INPUT
))
INPUT
.
E
at
(
1
);
INPUT
.
e
at
(
1
);
// if it's not a line break, then we ran into a bad character inline
if
(
INPUT
&&
!
Exp
::
Break
.
Matches
(
INPUT
))
...
...
stream.cpp
View file @
c1966ba3
...
...
@@ -2,9 +2,9 @@
namespace
YAML
{
//
GetChar
//
get
// . Extracts a character from the stream and updates our position
char
Stream
::
GetChar
()
char
Stream
::
get
()
{
char
ch
=
input
.
get
();
column
++
;
...
...
@@ -15,21 +15,21 @@ namespace YAML
return
ch
;
}
//
GetChar
//
get
// . Extracts 'n' characters from the stream and updates our position
std
::
string
Stream
::
GetChar
(
int
n
)
std
::
string
Stream
::
get
(
int
n
)
{
std
::
string
ret
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
ret
+=
GetChar
();
ret
+=
get
();
return
ret
;
}
//
E
at
//
e
at
// . Eats 'n' characters and updates our position.
void
Stream
::
E
at
(
int
n
)
void
Stream
::
e
at
(
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
GetChar
();
get
();
}
}
stream.h
View file @
c1966ba3
...
...
@@ -9,15 +9,15 @@ namespace YAML
{
Stream
(
std
::
istream
&
input_
)
:
input
(
input_
),
line
(
0
),
column
(
0
)
{}
char
peek
()
{
return
input
.
peek
();
}
int
pos
()
const
{
return
input
.
tellg
();
}
operator
std
::
istream
&
()
{
return
input
;
}
operator
bool
()
{
return
input
.
good
();
}
bool
operator
!
()
{
return
!
input
;
}
char
GetChar
();
std
::
string
GetChar
(
int
n
);
void
Eat
(
int
n
=
1
);
char
peek
()
{
return
input
.
peek
();
}
char
get
();
std
::
string
get
(
int
n
);
void
eat
(
int
n
=
1
);
std
::
istream
&
input
;
int
line
,
column
;
...
...
test.yaml
View file @
c1966ba3
---
Time
:
2001-11-23 15:01:42 -5
User
:
ed
Warning
:
This is an error message
for the log file
---
Time
:
2001-11-23 15:02:31 -5
User
:
ed
Warning
:
A slightly different error
message.
---
Date
:
2001-11-23 15:03:17 -5
User
:
ed
Fatal
:
Unknown variable "bar"
Stack
:
-
file
:
TopClass.py
line
:
23
code
:
|
x = MoreObject("345\n")
-
file
:
MoreClass.py
line
:
58
code
:
|
-
foo = bar
\ No newline at end of file
model
:
file
:
data/models/compound.model
textures
:
data/materials/compound
rooms
:
-
name
:
"
Room
#1"
pos
:
[
0
,
0
,
0
]
size
:
[
1000
,
1000
,
500
]
height
:
500
stairtype
:
none
display
:
[]
pathfinding
:
tilesize
:
50
size
:
[
24
,
24
]
map
:
|
-----------------------
-+++++++++++++++++++++-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+---------------------
-+---------------------
-+---------------------
-+---------------------
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+++++++++++++++++++++-
-----------------------
-
name
:
Doorway
pos
:
[
1000
,
400
,
0
]
size
:
[
50
,
200
,
500
]
height
:
500
stairtype
:
none
display
:
[]
pathfinding
:
tilesize
:
50
size
:
[
5
,
9
]
map
:
|
-----
-+++-
-----
-----
-----
-----
-----
-+++-
-----
-
name
:
"
Room
#2"
pos
:
[
1050
,
0
,
0
]
size
:
[
1000
,
1000
,
500
]
height
:
500
stairtype
:
none
display
:
[]
pathfinding
:
tilesize
:
50
size
:
[
24
,
24
]
map
:
|
-----------------------
-+++++++++++++++++++++-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
---------------------+-
---------------------+-
---------------------+-
---------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+++++++++++++++++++++-
-----------------------
exits
:
-
room1
:
"
Room
#1"
room2
:
"
Room
#2"
dir
:
e
pos
:
[
400
,
600
]
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