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
b51a32ae
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "b1dad2e9d33b9c70bdadcc1263be47ed11699dc1"
Commit
b51a32ae
authored
May 22, 2009
by
Jesse Beder
Browse files
Replaced direct emitter writing with an accessor to a C-string
parent
69ef8552
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
16 deletions
+11
-16
include/emitter.h
include/emitter.h
+3
-2
include/ostream.h
include/ostream.h
+1
-0
src/emitter.cpp
src/emitter.cpp
+4
-10
yaml-reader/tests.cpp
yaml-reader/tests.cpp
+3
-4
No files found.
include/emitter.h
View file @
b51a32ae
...
@@ -15,8 +15,9 @@ namespace YAML
...
@@ -15,8 +15,9 @@ namespace YAML
Emitter
();
Emitter
();
~
Emitter
();
~
Emitter
();
bool
WriteToStream
(
std
::
ostream
&
out
)
const
;
// output
bool
WriteToFile
(
const
std
::
string
&
fileName
)
const
;
const
char
*
c_str
()
const
;
unsigned
size
()
const
;
// state checking
// state checking
bool
good
()
const
;
bool
good
()
const
;
...
...
include/ostream.h
View file @
b51a32ae
...
@@ -16,6 +16,7 @@ namespace YAML
...
@@ -16,6 +16,7 @@ namespace YAML
unsigned
row
()
const
{
return
m_row
;
}
unsigned
row
()
const
{
return
m_row
;
}
unsigned
col
()
const
{
return
m_col
;
}
unsigned
col
()
const
{
return
m_col
;
}
unsigned
pos
()
const
{
return
m_pos
;
}
private:
private:
char
*
m_buffer
;
char
*
m_buffer
;
...
...
src/emitter.cpp
View file @
b51a32ae
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include "emitterutils.h"
#include "emitterutils.h"
#include "indentation.h"
#include "indentation.h"
#include "exceptions.h"
#include "exceptions.h"
#include <fstream>
#include <sstream>
#include <sstream>
namespace
YAML
namespace
YAML
...
@@ -16,19 +15,14 @@ namespace YAML
...
@@ -16,19 +15,14 @@ namespace YAML
{
{
}
}
bool
Emitter
::
WriteToStream
(
std
::
ostream
&
out
)
const
const
char
*
Emitter
::
c_str
(
)
const
{
{
out
<<
m_stream
.
str
();
return
m_stream
.
str
();
return
true
;
}
}
bool
Emitter
::
WriteToFile
(
const
std
::
string
&
fileName
)
const
unsigned
Emitter
::
size
(
)
const
{
{
std
::
ofstream
fout
(
fileName
.
c_str
());
return
m_stream
.
pos
();
if
(
!
fout
)
return
false
;
return
WriteToStream
(
fout
);
}
}
// state checking
// state checking
...
...
yaml-reader/tests.cpp
View file @
b51a32ae
...
@@ -101,16 +101,15 @@ namespace Test
...
@@ -101,16 +101,15 @@ namespace Test
YAML
::
Emitter
out
;
YAML
::
Emitter
out
;
std
::
string
desiredOutput
;
std
::
string
desiredOutput
;
test
(
out
,
desiredOutput
);
test
(
out
,
desiredOutput
);
std
::
stringstream
output
;
std
::
string
output
=
out
.
c_str
();
out
.
WriteToStream
(
output
);
if
(
output
.
str
()
==
desiredOutput
)
{
if
(
output
==
desiredOutput
)
{
std
::
cout
<<
"Test passed: "
<<
name
<<
"
\n
"
;
std
::
cout
<<
"Test passed: "
<<
name
<<
"
\n
"
;
}
else
{
}
else
{
passed
=
false
;
passed
=
false
;
std
::
cout
<<
"Test failed: "
<<
name
<<
"
\n
"
;
std
::
cout
<<
"Test failed: "
<<
name
<<
"
\n
"
;
std
::
cout
<<
"Output:
\n
"
;
std
::
cout
<<
"Output:
\n
"
;
std
::
cout
<<
output
.
str
()
<<
"<<<
\n
"
;
std
::
cout
<<
output
<<
"<<<
\n
"
;
std
::
cout
<<
"Desired output:
\n
"
;
std
::
cout
<<
"Desired output:
\n
"
;
std
::
cout
<<
desiredOutput
<<
"<<<
\n
"
;
std
::
cout
<<
desiredOutput
<<
"<<<
\n
"
;
}
}
...
...
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