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
c95bcae4
Commit
c95bcae4
authored
May 22, 2012
by
Jesse Beder
Browse files
Added writing integral types
parent
cc559956
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
7 deletions
+44
-7
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+12
-0
src/emitter.cpp
src/emitter.cpp
+31
-6
util/sandbox.cpp
util/sandbox.cpp
+1
-1
No files found.
include/yaml-cpp/emitter.h
View file @
c95bcae4
...
@@ -74,6 +74,9 @@ namespace YAML
...
@@ -74,6 +74,9 @@ namespace YAML
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
unsigned
GetFloatPrecision
()
const
;
unsigned
GetFloatPrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
void
PrepareIntegralStream
(
std
::
stringstream
&
stream
)
const
;
void
StartedScalar
();
private:
private:
void
EmitBeginDoc
();
void
EmitBeginDoc
();
...
@@ -111,6 +114,15 @@ namespace YAML
...
@@ -111,6 +114,15 @@ namespace YAML
if
(
!
good
())
if
(
!
good
())
return
*
this
;
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
PrepareIntegralStream
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
...
src/emitter.cpp
View file @
c95bcae4
...
@@ -436,6 +436,31 @@ namespace YAML
...
@@ -436,6 +436,31 @@ namespace YAML
m_stream
<<
IndentTo
(
indent
);
m_stream
<<
IndentTo
(
indent
);
}
}
void
Emitter
::
PrepareIntegralStream
(
std
::
stringstream
&
stream
)
const
{
switch
(
m_pState
->
GetIntFormat
())
{
case
Dec
:
stream
<<
std
::
dec
;
break
;
case
Hex
:
stream
<<
"0x"
;
stream
<<
std
::
hex
;
break
;
case
Oct
:
stream
<<
"0"
;
stream
<<
std
::
oct
;
break
;
default:
assert
(
false
);
}
}
void
Emitter
::
StartedScalar
()
{
m_pState
->
StartedScalar
();
}
// *******************************************************************************************
// *******************************************************************************************
// overloads of Write
// overloads of Write
...
@@ -464,7 +489,7 @@ namespace YAML
...
@@ -464,7 +489,7 @@ namespace YAML
break
;
break
;
}
}
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
@@ -521,7 +546,7 @@ namespace YAML
...
@@ -521,7 +546,7 @@ namespace YAML
PrepareNode
(
EmitterNodeType
::
Scalar
);
PrepareNode
(
EmitterNodeType
::
Scalar
);
m_stream
<<
ComputeFullBoolName
(
b
);
m_stream
<<
ComputeFullBoolName
(
b
);
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
@@ -533,7 +558,7 @@ namespace YAML
...
@@ -533,7 +558,7 @@ namespace YAML
PrepareNode
(
EmitterNodeType
::
Scalar
);
PrepareNode
(
EmitterNodeType
::
Scalar
);
m_stream
<<
ch
;
m_stream
<<
ch
;
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
@@ -555,7 +580,7 @@ namespace YAML
...
@@ -555,7 +580,7 @@ namespace YAML
return
*
this
;
return
*
this
;
}
}
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
@@ -639,7 +664,7 @@ namespace YAML
...
@@ -639,7 +664,7 @@ namespace YAML
return
*
this
;
return
*
this
;
// TODO
// TODO
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
@@ -653,7 +678,7 @@ namespace YAML
...
@@ -653,7 +678,7 @@ namespace YAML
PrepareNode
(
EmitterNodeType
::
Scalar
);
PrepareNode
(
EmitterNodeType
::
Scalar
);
Utils
::
WriteBinary
(
m_stream
,
binary
);
Utils
::
WriteBinary
(
m_stream
,
binary
);
m_pState
->
StartedScalar
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
...
...
util/sandbox.cpp
View file @
c95bcae4
...
@@ -10,7 +10,7 @@ int main()
...
@@ -10,7 +10,7 @@ int main()
out
<<
YAML
::
Anchor
(
"a"
)
<<
YAML
::
Comment
(
"anchor"
)
<<
"item 1"
<<
YAML
::
Comment
(
"a"
);
out
<<
YAML
::
Anchor
(
"a"
)
<<
YAML
::
Comment
(
"anchor"
)
<<
"item 1"
<<
YAML
::
Comment
(
"a"
);
out
<<
YAML
::
BeginMap
<<
YAML
::
Comment
(
"b"
);
out
<<
YAML
::
BeginMap
<<
YAML
::
Comment
(
"b"
);
out
<<
"pens"
<<
YAML
::
Comment
(
"foo"
)
<<
"a"
<<
YAML
::
Comment
(
"bar"
);
out
<<
"pens"
<<
YAML
::
Comment
(
"foo"
)
<<
"a"
<<
YAML
::
Comment
(
"bar"
);
out
<<
"pencils"
<<
"b"
;
out
<<
"pencils"
<<
15
;
out
<<
YAML
::
EndMap
<<
YAML
::
Comment
(
"monkey"
);
out
<<
YAML
::
EndMap
<<
YAML
::
Comment
(
"monkey"
);
out
<<
"item 2"
;
out
<<
"item 2"
;
out
<<
YAML
::
EndSeq
;
out
<<
YAML
::
EndSeq
;
...
...
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