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
1602f789
Commit
1602f789
authored
May 25, 2012
by
Jesse Beder
Browse files
Renamed ostream -> ostream_wrapper
parent
2dd1cf45
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
47 deletions
+47
-47
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+3
-3
include/yaml-cpp/ostream_wrapper.h
include/yaml-cpp/ostream_wrapper.h
+9
-9
src/emitterutils.cpp
src/emitterutils.cpp
+13
-13
src/emitterutils.h
src/emitterutils.h
+11
-11
src/indentation.h
src/indentation.h
+3
-3
src/ostream_wrapper.cpp
src/ostream_wrapper.cpp
+8
-8
No files found.
include/yaml-cpp/emitter.h
View file @
1602f789
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
#include "yaml-cpp/binary.h"
#include "yaml-cpp/binary.h"
#include "yaml-cpp/emitterdef.h"
#include "yaml-cpp/emitterdef.h"
#include "yaml-cpp/emittermanip.h"
#include "yaml-cpp/emittermanip.h"
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/noncopyable.h"
#include "yaml-cpp/noncopyable.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/ostream_wrapper.h"
#include <memory>
#include <memory>
#include <string>
#include <string>
#include <sstream>
#include <sstream>
...
@@ -114,8 +114,8 @@ namespace YAML
...
@@ -114,8 +114,8 @@ namespace YAML
bool
CanEmitNewline
()
const
;
bool
CanEmitNewline
()
const
;
private:
private:
ostream
m_stream
;
ostream
_wrapper
m_stream
;
std
::
auto_ptr
<
EmitterState
>
m_pState
;
std
::
auto_ptr
<
EmitterState
>
m_pState
;
};
};
template
<
typename
T
>
template
<
typename
T
>
...
...
include/yaml-cpp/ostream.h
→
include/yaml-cpp/ostream
_wrapper
.h
View file @
1602f789
#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef OSTREAM_
WRAPPER_
H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define OSTREAM_
WRAPPER_
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
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#pragma once
...
@@ -10,11 +10,11 @@
...
@@ -10,11 +10,11 @@
namespace
YAML
namespace
YAML
{
{
class
ostream
class
ostream
_wrapper
{
{
public:
public:
ostream
();
ostream
_wrapper
();
~
ostream
();
~
ostream
_wrapper
();
void
reserve
(
unsigned
size
);
void
reserve
(
unsigned
size
);
void
put
(
char
ch
);
void
put
(
char
ch
);
...
@@ -35,9 +35,9 @@ namespace YAML
...
@@ -35,9 +35,9 @@ namespace YAML
bool
m_comment
;
bool
m_comment
;
};
};
ostream
&
operator
<<
(
ostream
&
out
,
const
char
*
str
);
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
char
*
str
);
ostream
&
operator
<<
(
ostream
&
out
,
const
std
::
string
&
str
);
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
);
ostream
&
operator
<<
(
ostream
&
out
,
char
ch
);
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
char
ch
);
}
}
#endif // OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // OSTREAM_
WRAPPER_
H_62B23520_7C8E_11DE_8A39_0800200C9A66
src/emitterutils.cpp
View file @
1602f789
...
@@ -107,7 +107,7 @@ namespace YAML
...
@@ -107,7 +107,7 @@ namespace YAML
return
true
;
return
true
;
}
}
void
WriteCodePoint
(
ostream
&
out
,
int
codePoint
)
{
void
WriteCodePoint
(
ostream
_wrapper
&
out
,
int
codePoint
)
{
if
(
codePoint
<
0
||
codePoint
>
0x10FFFF
)
{
if
(
codePoint
<
0
||
codePoint
>
0x10FFFF
)
{
codePoint
=
REPLACEMENT_CHARACTER
;
codePoint
=
REPLACEMENT_CHARACTER
;
}
}
...
@@ -185,7 +185,7 @@ namespace YAML
...
@@ -185,7 +185,7 @@ namespace YAML
return
true
;
return
true
;
}
}
void
WriteDoubleQuoteEscapeSequence
(
ostream
&
out
,
int
codePoint
)
{
void
WriteDoubleQuoteEscapeSequence
(
ostream
_wrapper
&
out
,
int
codePoint
)
{
static
const
char
hexDigits
[]
=
"0123456789abcdef"
;
static
const
char
hexDigits
[]
=
"0123456789abcdef"
;
char
escSeq
[]
=
"
\\
U00000000"
;
char
escSeq
[]
=
"
\\
U00000000"
;
...
@@ -208,7 +208,7 @@ namespace YAML
...
@@ -208,7 +208,7 @@ namespace YAML
out
<<
escSeq
;
out
<<
escSeq
;
}
}
bool
WriteAliasName
(
ostream
&
out
,
const
std
::
string
&
str
)
{
bool
WriteAliasName
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
)
{
int
codePoint
;
int
codePoint
;
for
(
std
::
string
::
const_iterator
i
=
str
.
begin
();
for
(
std
::
string
::
const_iterator
i
=
str
.
begin
();
GetNextCodePointAndAdvance
(
codePoint
,
i
,
str
.
end
());
GetNextCodePointAndAdvance
(
codePoint
,
i
,
str
.
end
());
...
@@ -247,7 +247,7 @@ namespace YAML
...
@@ -247,7 +247,7 @@ namespace YAML
return
StringFormat
::
DoubleQuoted
;
return
StringFormat
::
DoubleQuoted
;
}
}
bool
WriteSingleQuotedString
(
ostream
&
out
,
const
std
::
string
&
str
)
bool
WriteSingleQuotedString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
)
{
{
out
<<
"'"
;
out
<<
"'"
;
int
codePoint
;
int
codePoint
;
...
@@ -267,7 +267,7 @@ namespace YAML
...
@@ -267,7 +267,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteDoubleQuotedString
(
ostream
&
out
,
const
std
::
string
&
str
,
bool
escapeNonAscii
)
bool
WriteDoubleQuotedString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
bool
escapeNonAscii
)
{
{
out
<<
"
\"
"
;
out
<<
"
\"
"
;
int
codePoint
;
int
codePoint
;
...
@@ -297,7 +297,7 @@ namespace YAML
...
@@ -297,7 +297,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteLiteralString
(
ostream
&
out
,
const
std
::
string
&
str
,
int
indent
)
bool
WriteLiteralString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
int
indent
)
{
{
out
<<
"|
\n
"
;
out
<<
"|
\n
"
;
out
<<
IndentTo
(
indent
);
out
<<
IndentTo
(
indent
);
...
@@ -314,7 +314,7 @@ namespace YAML
...
@@ -314,7 +314,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteChar
(
ostream
&
out
,
char
ch
)
bool
WriteChar
(
ostream
_wrapper
&
out
,
char
ch
)
{
{
if
((
'a'
<=
ch
&&
ch
<=
'z'
)
||
(
'A'
<=
ch
&&
ch
<=
'Z'
))
if
((
'a'
<=
ch
&&
ch
<=
'z'
)
||
(
'A'
<=
ch
&&
ch
<=
'Z'
))
out
<<
ch
;
out
<<
ch
;
...
@@ -334,7 +334,7 @@ namespace YAML
...
@@ -334,7 +334,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteComment
(
ostream
&
out
,
const
std
::
string
&
str
,
int
postCommentIndent
)
bool
WriteComment
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
int
postCommentIndent
)
{
{
const
unsigned
curIndent
=
out
.
col
();
const
unsigned
curIndent
=
out
.
col
();
out
<<
"#"
<<
Indentation
(
postCommentIndent
);
out
<<
"#"
<<
Indentation
(
postCommentIndent
);
...
@@ -354,19 +354,19 @@ namespace YAML
...
@@ -354,19 +354,19 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteAlias
(
ostream
&
out
,
const
std
::
string
&
str
)
bool
WriteAlias
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
)
{
{
out
<<
"*"
;
out
<<
"*"
;
return
WriteAliasName
(
out
,
str
);
return
WriteAliasName
(
out
,
str
);
}
}
bool
WriteAnchor
(
ostream
&
out
,
const
std
::
string
&
str
)
bool
WriteAnchor
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
)
{
{
out
<<
"&"
;
out
<<
"&"
;
return
WriteAliasName
(
out
,
str
);
return
WriteAliasName
(
out
,
str
);
}
}
bool
WriteTag
(
ostream
&
out
,
const
std
::
string
&
str
,
bool
verbatim
)
bool
WriteTag
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
bool
verbatim
)
{
{
out
<<
(
verbatim
?
"!<"
:
"!"
);
out
<<
(
verbatim
?
"!<"
:
"!"
);
StringCharSource
buffer
(
str
.
c_str
(),
str
.
size
());
StringCharSource
buffer
(
str
.
c_str
(),
str
.
size
());
...
@@ -386,7 +386,7 @@ namespace YAML
...
@@ -386,7 +386,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteTagWithPrefix
(
ostream
&
out
,
const
std
::
string
&
prefix
,
const
std
::
string
&
tag
)
bool
WriteTagWithPrefix
(
ostream
_wrapper
&
out
,
const
std
::
string
&
prefix
,
const
std
::
string
&
tag
)
{
{
out
<<
"!"
;
out
<<
"!"
;
StringCharSource
prefixBuffer
(
prefix
.
c_str
(),
prefix
.
size
());
StringCharSource
prefixBuffer
(
prefix
.
c_str
(),
prefix
.
size
());
...
@@ -416,7 +416,7 @@ namespace YAML
...
@@ -416,7 +416,7 @@ namespace YAML
return
true
;
return
true
;
}
}
bool
WriteBinary
(
ostream
&
out
,
const
Binary
&
binary
)
bool
WriteBinary
(
ostream
_wrapper
&
out
,
const
Binary
&
binary
)
{
{
WriteDoubleQuotedString
(
out
,
EncodeBase64
(
binary
.
data
(),
binary
.
size
()),
false
);
WriteDoubleQuotedString
(
out
,
EncodeBase64
(
binary
.
data
(),
binary
.
size
()),
false
);
return
true
;
return
true
;
...
...
src/emitterutils.h
View file @
1602f789
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "emitterstate.h"
#include "emitterstate.h"
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream
_wrapper
.h"
#include <string>
#include <string>
namespace
YAML
namespace
YAML
...
@@ -20,16 +20,16 @@ namespace YAML
...
@@ -20,16 +20,16 @@ namespace YAML
{
{
StringFormat
::
value
ComputeStringFormat
(
const
std
::
string
&
str
,
EMITTER_MANIP
strFormat
,
FlowType
::
value
flowType
,
bool
escapeNonAscii
);
StringFormat
::
value
ComputeStringFormat
(
const
std
::
string
&
str
,
EMITTER_MANIP
strFormat
,
FlowType
::
value
flowType
,
bool
escapeNonAscii
);
bool
WriteSingleQuotedString
(
ostream
&
out
,
const
std
::
string
&
str
);
bool
WriteSingleQuotedString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
);
bool
WriteDoubleQuotedString
(
ostream
&
out
,
const
std
::
string
&
str
,
bool
escapeNonAscii
);
bool
WriteDoubleQuotedString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
bool
escapeNonAscii
);
bool
WriteLiteralString
(
ostream
&
out
,
const
std
::
string
&
str
,
int
indent
);
bool
WriteLiteralString
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
int
indent
);
bool
WriteChar
(
ostream
&
out
,
char
ch
);
bool
WriteChar
(
ostream
_wrapper
&
out
,
char
ch
);
bool
WriteComment
(
ostream
&
out
,
const
std
::
string
&
str
,
int
postCommentIndent
);
bool
WriteComment
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
int
postCommentIndent
);
bool
WriteAlias
(
ostream
&
out
,
const
std
::
string
&
str
);
bool
WriteAlias
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
);
bool
WriteAnchor
(
ostream
&
out
,
const
std
::
string
&
str
);
bool
WriteAnchor
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
);
bool
WriteTag
(
ostream
&
out
,
const
std
::
string
&
str
,
bool
verbatim
);
bool
WriteTag
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
,
bool
verbatim
);
bool
WriteTagWithPrefix
(
ostream
&
out
,
const
std
::
string
&
prefix
,
const
std
::
string
&
tag
);
bool
WriteTagWithPrefix
(
ostream
_wrapper
&
out
,
const
std
::
string
&
prefix
,
const
std
::
string
&
tag
);
bool
WriteBinary
(
ostream
&
out
,
const
Binary
&
binary
);
bool
WriteBinary
(
ostream
_wrapper
&
out
,
const
Binary
&
binary
);
}
}
}
}
...
...
src/indentation.h
View file @
1602f789
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#endif
#endif
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream
_wrapper
.h"
#include <iostream>
#include <iostream>
namespace
YAML
namespace
YAML
...
@@ -16,7 +16,7 @@ namespace YAML
...
@@ -16,7 +16,7 @@ namespace YAML
unsigned
n
;
unsigned
n
;
};
};
inline
ostream
&
operator
<<
(
ostream
&
out
,
const
Indentation
&
indent
)
{
inline
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
Indentation
&
indent
)
{
for
(
unsigned
i
=
0
;
i
<
indent
.
n
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
indent
.
n
;
i
++
)
out
<<
' '
;
out
<<
' '
;
return
out
;
return
out
;
...
@@ -27,7 +27,7 @@ namespace YAML
...
@@ -27,7 +27,7 @@ namespace YAML
unsigned
n
;
unsigned
n
;
};
};
inline
ostream
&
operator
<<
(
ostream
&
out
,
const
IndentTo
&
indent
)
{
inline
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
IndentTo
&
indent
)
{
while
(
out
.
col
()
<
indent
.
n
)
while
(
out
.
col
()
<
indent
.
n
)
out
<<
' '
;
out
<<
' '
;
return
out
;
return
out
;
...
...
src/ostream.cpp
→
src/ostream
_wrapper
.cpp
View file @
1602f789
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream
_wrapper
.h"
#include <cstring>
#include <cstring>
namespace
YAML
namespace
YAML
{
{
ostream
::
ostream
()
:
m_buffer
(
0
),
m_pos
(
0
),
m_size
(
0
),
m_row
(
0
),
m_col
(
0
),
m_comment
(
false
)
ostream
_wrapper
::
ostream
_wrapper
()
:
m_buffer
(
0
),
m_pos
(
0
),
m_size
(
0
),
m_row
(
0
),
m_col
(
0
),
m_comment
(
false
)
{
{
reserve
(
1024
);
reserve
(
1024
);
}
}
ostream
::~
ostream
()
ostream
_wrapper
::~
ostream
_wrapper
()
{
{
delete
[]
m_buffer
;
delete
[]
m_buffer
;
}
}
void
ostream
::
reserve
(
unsigned
size
)
void
ostream
_wrapper
::
reserve
(
unsigned
size
)
{
{
if
(
size
<=
m_size
)
if
(
size
<=
m_size
)
return
;
return
;
...
@@ -26,7 +26,7 @@ namespace YAML
...
@@ -26,7 +26,7 @@ namespace YAML
m_size
=
size
;
m_size
=
size
;
}
}
void
ostream
::
put
(
char
ch
)
void
ostream
_wrapper
::
put
(
char
ch
)
{
{
if
(
m_pos
>=
m_size
-
1
)
// an extra space for the NULL terminator
if
(
m_pos
>=
m_size
-
1
)
// an extra space for the NULL terminator
reserve
(
m_size
*
2
);
reserve
(
m_size
*
2
);
...
@@ -42,7 +42,7 @@ namespace YAML
...
@@ -42,7 +42,7 @@ namespace YAML
m_col
++
;
m_col
++
;
}
}
ostream
&
operator
<<
(
ostream
&
out
,
const
char
*
str
)
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
char
*
str
)
{
{
std
::
size_t
length
=
std
::
strlen
(
str
);
std
::
size_t
length
=
std
::
strlen
(
str
);
for
(
std
::
size_t
i
=
0
;
i
<
length
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
length
;
i
++
)
...
@@ -50,13 +50,13 @@ namespace YAML
...
@@ -50,13 +50,13 @@ namespace YAML
return
out
;
return
out
;
}
}
ostream
&
operator
<<
(
ostream
&
out
,
const
std
::
string
&
str
)
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
const
std
::
string
&
str
)
{
{
out
<<
str
.
c_str
();
out
<<
str
.
c_str
();
return
out
;
return
out
;
}
}
ostream
&
operator
<<
(
ostream
&
out
,
char
ch
)
ostream
_wrapper
&
operator
<<
(
ostream
_wrapper
&
out
,
char
ch
)
{
{
out
.
put
(
ch
);
out
.
put
(
ch
);
return
out
;
return
out
;
...
...
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