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
33a71151
Commit
33a71151
authored
Sep 10, 2011
by
beder
Browse files
Added helper emitter functions, but we have a problem: YAML::Value is already a manipulator
parent
59ce694c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
4 deletions
+47
-4
include/yaml-cpp/value.h
include/yaml-cpp/value.h
+1
-0
include/yaml-cpp/value/emit.h
include/yaml-cpp/value/emit.h
+21
-0
src/value/emit.cpp
src/value/emit.cpp
+23
-0
src/value/valueevents.h
src/value/valueevents.h
+1
-1
util/value.cpp
util/value.cpp
+1
-3
No files found.
include/yaml-cpp/value.h
View file @
33a71151
...
...
@@ -12,5 +12,6 @@
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/detail/impl.h"
#include "yaml-cpp/value/parse.h"
#include "yaml-cpp/value/emit.h"
#endif // VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/value/emit.h
0 → 100644
View file @
33a71151
#ifndef VALUE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include <string>
#include <iosfwd>
namespace
YAML
{
class
Emitter
;
class
Value
;
Emitter
&
operator
<<
(
Emitter
&
out
,
const
foo
&
value
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Value
&
value
);
}
#endif // VALUE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/value/emit.cpp
0 → 100644
View file @
33a71151
#include "yaml-cpp/value/emit.h"
#include "yaml-cpp/emitfromevents.h"
#include "yaml-cpp/emitter.h"
#include "valueevents.h"
namespace
YAML
{
Emitter
&
operator
<<
(
Emitter
&
out
,
const
Value
&
value
)
{
EmitFromEvents
emitFromEvents
(
out
);
ValueEvents
events
(
value
);
events
.
Emit
(
emitFromEvents
);
return
out
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Value
&
value
)
{
Emitter
emitter
;
emitter
<<
value
;
out
<<
emitter
.
c_str
();
return
out
;
}
}
src/value/valueevents.h
View file @
33a71151
...
...
@@ -18,7 +18,7 @@ namespace YAML
class
ValueEvents
{
public:
ValueEvents
(
const
Value
&
value
);
explicit
ValueEvents
(
const
Value
&
value
);
void
Emit
(
EventHandler
&
handler
);
...
...
util/value.cpp
View file @
33a71151
...
...
@@ -4,9 +4,7 @@
int
main
()
{
YAML
::
Value
value
=
YAML
::
Parse
(
"{foo: bar, monkey: value}"
);
for
(
YAML
::
const_iterator
it
=
value
.
begin
();
it
!=
value
.
end
();
++
it
)
{
std
::
cout
<<
it
->
first
.
as
<
std
::
string
>
()
<<
" -> "
<<
it
->
second
.
as
<
std
::
string
>
()
<<
"
\n
"
;
}
std
::
cout
<<
value
<<
"
\n
"
;
return
0
;
}
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