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
08148133
Commit
08148133
authored
May 22, 2012
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments, not entirely correct
parent
0f3f1e26
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
4 deletions
+18
-4
include/yaml-cpp/ostream.h
+3
-0
src/emitter.cpp
+7
-1
src/emitterutils.cpp
+5
-2
src/ostream.cpp
+2
-1
util/sandbox.cpp
+1
-0
No files found.
include/yaml-cpp/ostream.h
View file @
08148133
...
...
@@ -18,11 +18,13 @@ namespace YAML
void
reserve
(
unsigned
size
);
void
put
(
char
ch
);
void
set_comment
()
{
m_comment
=
true
;
}
const
char
*
str
()
const
{
return
m_buffer
;
}
unsigned
row
()
const
{
return
m_row
;
}
unsigned
col
()
const
{
return
m_col
;
}
unsigned
pos
()
const
{
return
m_pos
;
}
bool
comment
()
const
{
return
m_comment
;
}
private
:
char
*
m_buffer
;
...
...
@@ -30,6 +32,7 @@ namespace YAML
unsigned
m_size
;
unsigned
m_row
,
m_col
;
bool
m_comment
;
};
ostream
&
operator
<<
(
ostream
&
out
,
const
char
*
str
);
...
...
src/emitter.cpp
View file @
08148133
...
...
@@ -589,7 +589,13 @@ namespace YAML
if
(
!
good
())
return
*
this
;
m_pState
->
StartedScalar
();
PrepareNode
(
EmitterNodeType
::
None
);
if
(
m_stream
.
col
()
>
0
)
m_stream
<<
Indentation
(
m_pState
->
GetPreCommentIndent
());
Utils
::
WriteComment
(
m_stream
,
comment
.
content
,
m_pState
->
GetPostCommentIndent
());
m_pState
->
SetNonContent
();
return
*
this
;
}
...
...
src/emitterutils.cpp
View file @
08148133
...
...
@@ -333,15 +333,18 @@ namespace YAML
{
const
unsigned
curIndent
=
out
.
col
();
out
<<
"#"
<<
Indentation
(
postCommentIndent
);
out
.
set_comment
();
int
codePoint
;
for
(
std
::
string
::
const_iterator
i
=
str
.
begin
();
GetNextCodePointAndAdvance
(
codePoint
,
i
,
str
.
end
());
)
{
if
(
codePoint
==
'\n'
)
if
(
codePoint
==
'\n'
)
{
out
<<
"
\n
"
<<
IndentTo
(
curIndent
)
<<
"#"
<<
Indentation
(
postCommentIndent
);
else
out
.
set_comment
();
}
else
{
WriteCodePoint
(
out
,
codePoint
);
}
}
return
true
;
}
...
...
src/ostream.cpp
View file @
08148133
...
...
@@ -3,7 +3,7 @@
namespace
YAML
{
ostream
::
ostream
()
:
m_buffer
(
0
),
m_pos
(
0
),
m_size
(
0
),
m_row
(
0
),
m_col
(
0
)
ostream
::
ostream
()
:
m_buffer
(
0
),
m_pos
(
0
),
m_size
(
0
),
m_row
(
0
),
m_col
(
0
)
,
m_comment
(
false
)
{
reserve
(
1024
);
}
...
...
@@ -37,6 +37,7 @@ namespace YAML
if
(
ch
==
'\n'
)
{
m_row
++
;
m_col
=
0
;
m_comment
=
false
;
}
else
m_col
++
;
}
...
...
util/sandbox.cpp
View file @
08148133
...
...
@@ -4,6 +4,7 @@
int
main
()
{
YAML
::
Emitter
out
;
out
<<
YAML
::
Comment
(
"Hello"
);
out
<<
YAML
::
BeginSeq
;
out
<<
"item 1"
;
out
<<
YAML
::
BeginMap
;
...
...
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