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
952fe51c
Commit
952fe51c
authored
May 22, 2012
by
Jesse Beder
Browse files
Added writing float/double
parent
c95bcae4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+13
-4
util/sandbox.cpp
util/sandbox.cpp
+1
-1
No files found.
include/yaml-cpp/emitter.h
View file @
952fe51c
...
@@ -132,19 +132,28 @@ namespace YAML
...
@@ -132,19 +132,28 @@ namespace YAML
if
(
!
good
())
if
(
!
good
())
return
*
this
;
return
*
this
;
PrepareNode
(
EmitterNodeType
::
Scalar
);
std
::
stringstream
stream
;
SetStreamablePrecision
<
T
>
(
stream
);
stream
<<
value
;
m_stream
<<
stream
.
str
();
StartedScalar
();
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
float
>
(
std
::
stringstream
&
str
)
inline
void
Emitter
::
SetStreamablePrecision
<
float
>
(
std
::
stringstream
&
str
eam
)
{
{
str
.
precision
(
GetFloatPrecision
());
str
eam
.
precision
(
GetFloatPrecision
());
}
}
template
<
>
template
<
>
inline
void
Emitter
::
SetStreamablePrecision
<
double
>
(
std
::
stringstream
&
str
)
inline
void
Emitter
::
SetStreamablePrecision
<
double
>
(
std
::
stringstream
&
str
eam
)
{
{
str
.
precision
(
GetDoublePrecision
());
str
eam
.
precision
(
GetDoublePrecision
());
}
}
// overloads of insertion
// overloads of insertion
...
...
util/sandbox.cpp
View file @
952fe51c
...
@@ -9,7 +9,7 @@ int main()
...
@@ -9,7 +9,7 @@ int main()
out
<<
YAML
::
Comment
(
"Hello"
);
out
<<
YAML
::
Comment
(
"Hello"
);
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"
)
<<
2.3
<<
YAML
::
Comment
(
"bar"
);
out
<<
"pencils"
<<
15
;
out
<<
"pencils"
<<
15
;
out
<<
YAML
::
EndMap
<<
YAML
::
Comment
(
"monkey"
);
out
<<
YAML
::
EndMap
<<
YAML
::
Comment
(
"monkey"
);
out
<<
"item 2"
;
out
<<
"item 2"
;
...
...
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