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
0c8a5393
Commit
0c8a5393
authored
Jan 24, 2015
by
Jesse Beder
Browse files
Fix warnings on visual studio, including changing unsigned to std::size_t
parent
ad712c4f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
66 additions
and
58 deletions
+66
-58
CMakeLists.txt
CMakeLists.txt
+1
-1
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+9
-8
src/emitter.cpp
src/emitter.cpp
+20
-20
src/emitterstate.cpp
src/emitterstate.cpp
+6
-4
src/emitterstate.h
src/emitterstate.h
+8
-8
src/emitterutils.cpp
src/emitterutils.cpp
+1
-1
src/indentation.h
src/indentation.h
+8
-6
src/ostream_wrapper.cpp
src/ostream_wrapper.cpp
+2
-2
src/ptr_stack.h
src/ptr_stack.h
+3
-2
src/ptr_vector.h
src/ptr_vector.h
+3
-2
src/scanner.h
src/scanner.h
+4
-3
src/simplekey.cpp
src/simplekey.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
0c8a5393
...
...
@@ -238,7 +238,7 @@ if(MSVC)
# /W3 = set warning level; see http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
# /wd4127 = disable warning C4127 "conditional expression is constant"; see http://msdn.microsoft.com/en-us/library/6t66728h.aspx
# /wd4355 = disable warning C4355 "'this' : used in base member initializer list"; http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
set
(
yaml_cxx_flags
"/W3 /wd4127 /wd4355
/D_SCL_SECURE_NO_WARNINGS
${
yaml_cxx_flags
}
"
)
set
(
yaml_cxx_flags
"/W3 /wd4127 /wd4355
${
yaml_cxx_flags
}
"
)
endif
()
...
...
include/yaml-cpp/emitter.h
View file @
0c8a5393
...
...
@@ -7,6 +7,7 @@
#pragma once
#endif
#include <cstddef>
#include <memory>
#include <sstream>
#include <string>
...
...
@@ -48,11 +49,11 @@ class YAML_CPP_API Emitter : private noncopyable {
bool
SetIntBase
(
EMITTER_MANIP
value
);
bool
SetSeqFormat
(
EMITTER_MANIP
value
);
bool
SetMapFormat
(
EMITTER_MANIP
value
);
bool
SetIndent
(
unsigned
n
);
bool
SetPreCommentIndent
(
unsigned
n
);
bool
SetPostCommentIndent
(
unsigned
n
);
bool
SetFloatPrecision
(
unsigned
n
);
bool
SetDoublePrecision
(
unsigned
n
);
bool
SetIndent
(
std
::
size_t
n
);
bool
SetPreCommentIndent
(
std
::
size_t
n
);
bool
SetPostCommentIndent
(
std
::
size_t
n
);
bool
SetFloatPrecision
(
std
::
size_t
n
);
bool
SetDoublePrecision
(
std
::
size_t
n
);
// local setters
Emitter
&
SetLocalValue
(
EMITTER_MANIP
value
);
...
...
@@ -79,8 +80,8 @@ class YAML_CPP_API Emitter : private noncopyable {
private:
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
unsigned
GetFloatPrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
std
::
size_t
GetFloatPrecision
()
const
;
std
::
size_t
GetDoublePrecision
()
const
;
void
PrepareIntegralStream
(
std
::
stringstream
&
stream
)
const
;
void
StartedScalar
();
...
...
@@ -115,7 +116,7 @@ class YAML_CPP_API Emitter : private noncopyable {
void
BlockMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
std
::
size_t
indent
);
const
char
*
ComputeFullBoolName
(
bool
b
)
const
;
bool
CanEmitNewline
()
const
;
...
...
src/emitter.cpp
View file @
0c8a5393
...
...
@@ -66,23 +66,23 @@ bool Emitter::SetMapFormat(EMITTER_MANIP value) {
return
ok
;
}
bool
Emitter
::
SetIndent
(
unsigned
n
)
{
bool
Emitter
::
SetIndent
(
std
::
size_t
n
)
{
return
m_pState
->
SetIndent
(
n
,
FmtScope
::
Global
);
}
bool
Emitter
::
SetPreCommentIndent
(
unsigned
n
)
{
bool
Emitter
::
SetPreCommentIndent
(
std
::
size_t
n
)
{
return
m_pState
->
SetPreCommentIndent
(
n
,
FmtScope
::
Global
);
}
bool
Emitter
::
SetPostCommentIndent
(
unsigned
n
)
{
bool
Emitter
::
SetPostCommentIndent
(
std
::
size_t
n
)
{
return
m_pState
->
SetPostCommentIndent
(
n
,
FmtScope
::
Global
);
}
bool
Emitter
::
SetFloatPrecision
(
unsigned
n
)
{
bool
Emitter
::
SetFloatPrecision
(
std
::
size_t
n
)
{
return
m_pState
->
SetFloatPrecision
(
n
,
FmtScope
::
Global
);
}
bool
Emitter
::
SetDoublePrecision
(
unsigned
n
)
{
bool
Emitter
::
SetDoublePrecision
(
std
::
size_t
n
)
{
return
m_pState
->
SetDoublePrecision
(
n
,
FmtScope
::
Global
);
}
...
...
@@ -310,7 +310,7 @@ void Emitter::PrepareTopNode(EmitterNodeType::value child) {
}
void
Emitter
::
FlowSeqPrepareNode
(
EmitterNodeType
::
value
child
)
{
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
const
std
::
size_t
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
...
...
@@ -341,8 +341,8 @@ void Emitter::FlowSeqPrepareNode(EmitterNodeType::value child) {
}
void
Emitter
::
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
const
std
::
size_t
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
if
(
child
==
EmitterNodeType
::
None
)
return
;
...
...
@@ -392,7 +392,7 @@ void Emitter::FlowMapPrepareNode(EmitterNodeType::value child) {
}
void
Emitter
::
FlowMapPrepareLongKey
(
EmitterNodeType
::
value
child
)
{
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
const
std
::
size_t
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
...
...
@@ -423,7 +423,7 @@ void Emitter::FlowMapPrepareLongKey(EmitterNodeType::value child) {
}
void
Emitter
::
FlowMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
const
std
::
size_t
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
...
...
@@ -451,7 +451,7 @@ void Emitter::FlowMapPrepareLongKeyValue(EmitterNodeType::value child) {
}
void
Emitter
::
FlowMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
)
{
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
const
std
::
size_t
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
...
...
@@ -482,7 +482,7 @@ void Emitter::FlowMapPrepareSimpleKey(EmitterNodeType::value child) {
}
void
Emitter
::
FlowMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
const
std
::
size_t
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
...
...
@@ -530,7 +530,7 @@ void Emitter::BlockMapPrepareNode(EmitterNodeType::value child) {
}
void
Emitter
::
BlockMapPrepareLongKey
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
childCount
=
m_pState
->
CurGroupChildCount
();
if
(
child
==
EmitterNodeType
::
None
)
...
...
@@ -563,7 +563,7 @@ void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child) {
}
void
Emitter
::
BlockMapPrepareLongKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
curIndent
=
m_pState
->
CurIndent
();
if
(
child
==
EmitterNodeType
::
None
)
return
;
...
...
@@ -589,7 +589,7 @@ void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child) {
}
void
Emitter
::
BlockMapPrepareSimpleKey
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
childCount
=
m_pState
->
CurGroupChildCount
();
if
(
child
==
EmitterNodeType
::
None
)
...
...
@@ -617,8 +617,8 @@ void Emitter::BlockMapPrepareSimpleKey(EmitterNodeType::value child) {
}
void
Emitter
::
BlockMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
const
std
::
size_t
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
m_stream
<<
":"
;
...
...
@@ -642,7 +642,7 @@ void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
// SpaceOrIndentTo
// . Prepares for some more content by proper spacing
void
Emitter
::
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
)
{
void
Emitter
::
SpaceOrIndentTo
(
bool
requireSpace
,
std
::
size_t
indent
)
{
if
(
m_stream
.
comment
())
m_stream
<<
"
\n
"
;
if
(
m_stream
.
col
()
>
0
&&
requireSpace
)
...
...
@@ -709,11 +709,11 @@ Emitter& Emitter::Write(const std::string& str) {
return
*
this
;
}
unsigned
Emitter
::
GetFloatPrecision
()
const
{
std
::
size_t
Emitter
::
GetFloatPrecision
()
const
{
return
m_pState
->
GetFloatPrecision
();
}
unsigned
Emitter
::
GetDoublePrecision
()
const
{
std
::
size_t
Emitter
::
GetDoublePrecision
()
const
{
return
m_pState
->
GetDoublePrecision
();
}
...
...
src/emitterstate.cpp
View file @
0c8a5393
...
...
@@ -155,7 +155,7 @@ void EmitterState::EndedGroup(GroupType::value type) {
}
// reset old settings
unsigned
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
().
indent
);
std
::
size_t
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
().
indent
);
assert
(
m_curIndent
>=
lastIndent
);
m_curIndent
-=
lastIndent
;
...
...
@@ -276,7 +276,7 @@ bool EmitterState::SetIntFormat(EMITTER_MANIP value, FmtScope::value scope) {
}
}
bool
EmitterState
::
SetIndent
(
unsigned
value
,
FmtScope
::
value
scope
)
{
bool
EmitterState
::
SetIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
)
{
if
(
value
<=
1
)
return
false
;
...
...
@@ -284,7 +284,8 @@ bool EmitterState::SetIndent(unsigned value, FmtScope::value scope) {
return
true
;
}
bool
EmitterState
::
SetPreCommentIndent
(
unsigned
value
,
FmtScope
::
value
scope
)
{
bool
EmitterState
::
SetPreCommentIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
)
{
if
(
value
==
0
)
return
false
;
...
...
@@ -292,7 +293,8 @@ bool EmitterState::SetPreCommentIndent(unsigned value, FmtScope::value scope) {
return
true
;
}
bool
EmitterState
::
SetPostCommentIndent
(
unsigned
value
,
FmtScope
::
value
scope
)
{
bool
EmitterState
::
SetPostCommentIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
)
{
if
(
value
==
0
)
return
false
;
...
...
src/emitterstate.h
View file @
0c8a5393
...
...
@@ -94,12 +94,12 @@ class EmitterState {
bool
SetIntFormat
(
EMITTER_MANIP
value
,
FmtScope
::
value
scope
);
EMITTER_MANIP
GetIntFormat
()
const
{
return
m_intFmt
.
get
();
}
bool
SetIndent
(
unsigned
value
,
FmtScope
::
value
scope
);
bool
SetIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
);
int
GetIndent
()
const
{
return
m_indent
.
get
();
}
bool
SetPreCommentIndent
(
unsigned
value
,
FmtScope
::
value
scope
);
bool
SetPreCommentIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
);
int
GetPreCommentIndent
()
const
{
return
m_preCommentIndent
.
get
();
}
bool
SetPostCommentIndent
(
unsigned
value
,
FmtScope
::
value
scope
);
bool
SetPostCommentIndent
(
std
::
size_t
value
,
FmtScope
::
value
scope
);
int
GetPostCommentIndent
()
const
{
return
m_postCommentIndent
.
get
();
}
bool
SetFlowType
(
GroupType
::
value
groupType
,
EMITTER_MANIP
value
,
...
...
@@ -110,9 +110,9 @@ class EmitterState {
EMITTER_MANIP
GetMapKeyFormat
()
const
{
return
m_mapKeyFmt
.
get
();
}
bool
SetFloatPrecision
(
int
value
,
FmtScope
::
value
scope
);
unsigned
GetFloatPrecision
()
const
{
return
m_floatPrecision
.
get
();
}
std
::
size_t
GetFloatPrecision
()
const
{
return
m_floatPrecision
.
get
();
}
bool
SetDoublePrecision
(
int
value
,
FmtScope
::
value
scope
);
unsigned
GetDoublePrecision
()
const
{
return
m_doublePrecision
.
get
();
}
std
::
size_t
GetDoublePrecision
()
const
{
return
m_doublePrecision
.
get
();
}
private:
template
<
typename
T
>
...
...
@@ -132,8 +132,8 @@ class EmitterState {
Setting
<
EMITTER_MANIP
>
m_boolLengthFmt
;
Setting
<
EMITTER_MANIP
>
m_boolCaseFmt
;
Setting
<
EMITTER_MANIP
>
m_intFmt
;
Setting
<
unsigned
>
m_indent
;
Setting
<
unsigned
>
m_preCommentIndent
,
m_postCommentIndent
;
Setting
<
std
::
size_t
>
m_indent
;
Setting
<
std
::
size_t
>
m_preCommentIndent
,
m_postCommentIndent
;
Setting
<
EMITTER_MANIP
>
m_seqFmt
;
Setting
<
EMITTER_MANIP
>
m_mapFmt
;
Setting
<
EMITTER_MANIP
>
m_mapKeyFmt
;
...
...
@@ -175,7 +175,7 @@ class EmitterState {
};
ptr_stack
<
Group
>
m_groups
;
unsigned
m_curIndent
;
std
::
size_t
m_curIndent
;
bool
m_hasAnchor
;
bool
m_hasTag
;
bool
m_hasNonContent
;
...
...
src/emitterutils.cpp
View file @
0c8a5393
...
...
@@ -358,7 +358,7 @@ bool WriteChar(ostream_wrapper& out, char ch) {
bool
WriteComment
(
ostream_wrapper
&
out
,
const
std
::
string
&
str
,
int
postCommentIndent
)
{
const
unsigned
curIndent
=
out
.
col
();
const
std
::
size_t
curIndent
=
out
.
col
();
out
<<
"#"
<<
Indentation
(
postCommentIndent
);
out
.
set_comment
();
int
codePoint
;
...
...
src/indentation.h
View file @
0c8a5393
...
...
@@ -7,25 +7,27 @@
#pragma once
#endif
#include "yaml-cpp/ostream_wrapper.h"
#include <iostream>
#include <cstddef>
#include "yaml-cpp/ostream_wrapper.h"
namespace
YAML
{
struct
Indentation
{
Indentation
(
unsigned
n_
)
:
n
(
n_
)
{}
unsigned
n
;
Indentation
(
std
::
size_t
n_
)
:
n
(
n_
)
{}
std
::
size_t
n
;
};
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
out
,
const
Indentation
&
indent
)
{
for
(
unsigned
i
=
0
;
i
<
indent
.
n
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
indent
.
n
;
i
++
)
out
<<
' '
;
return
out
;
}
struct
IndentTo
{
IndentTo
(
unsigned
n_
)
:
n
(
n_
)
{}
unsigned
n
;
IndentTo
(
std
::
size_t
n_
)
:
n
(
n_
)
{}
std
::
size_t
n
;
};
inline
ostream_wrapper
&
operator
<<
(
ostream_wrapper
&
out
,
...
...
src/ostream_wrapper.cpp
View file @
0c8a5393
...
...
@@ -23,7 +23,7 @@ void ostream_wrapper::write(const std::string& str) {
m_pStream
->
write
(
str
.
c_str
(),
str
.
size
());
}
else
{
m_buffer
.
resize
(
std
::
max
(
m_buffer
.
size
(),
m_pos
+
str
.
size
()
+
1
));
std
::
copy
(
str
.
begin
(),
str
.
end
(),
&
m_buffer
[
m_pos
]
);
std
::
copy
(
str
.
begin
(),
str
.
end
(),
m_buffer
.
begin
()
+
m_pos
);
}
for
(
std
::
size_t
i
=
0
;
i
<
str
.
size
();
i
++
)
{
...
...
@@ -36,7 +36,7 @@ void ostream_wrapper::write(const char* str, std::size_t size) {
m_pStream
->
write
(
str
,
size
);
}
else
{
m_buffer
.
resize
(
std
::
max
(
m_buffer
.
size
(),
m_pos
+
size
+
1
));
std
::
copy
(
str
,
str
+
size
,
&
m_buffer
[
m_pos
]
);
std
::
copy
(
str
,
str
+
size
,
m_buffer
.
begin
()
+
m_pos
);
}
for
(
std
::
size_t
i
=
0
;
i
<
size
;
i
++
)
{
...
...
src/ptr_stack.h
View file @
0c8a5393
...
...
@@ -7,12 +7,13 @@
#pragma once
#endif
#include "yaml-cpp/noncopyable.h"
#include <cstddef>
#include <cstdlib>
#include <memory>
#include <vector>
#include "yaml-cpp/noncopyable.h"
template
<
typename
T
>
class
ptr_stack
:
private
YAML
::
noncopyable
{
public:
...
...
@@ -20,7 +21,7 @@ class ptr_stack : private YAML::noncopyable {
~
ptr_stack
()
{
clear
();
}
void
clear
()
{
for
(
unsigned
i
=
0
;
i
<
m_data
.
size
();
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
m_data
.
size
();
i
++
)
delete
m_data
[
i
];
m_data
.
clear
();
}
...
...
src/ptr_vector.h
View file @
0c8a5393
...
...
@@ -7,12 +7,13 @@
#pragma once
#endif
#include "yaml-cpp/noncopyable.h"
#include <cstddef>
#include <cstdlib>
#include <memory>
#include <vector>
#include "yaml-cpp/noncopyable.h"
namespace
YAML
{
template
<
typename
T
>
...
...
@@ -22,7 +23,7 @@ class ptr_vector : private YAML::noncopyable {
~
ptr_vector
()
{
clear
();
}
void
clear
()
{
for
(
unsigned
i
=
0
;
i
<
m_data
.
size
();
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
m_data
.
size
();
i
++
)
delete
m_data
[
i
];
m_data
.
clear
();
}
...
...
src/scanner.h
View file @
0c8a5393
...
...
@@ -7,6 +7,7 @@
#pragma once
#endif
#include <cstddef>
#include <ios>
#include <map>
#include <queue>
...
...
@@ -60,7 +61,7 @@ class Scanner {
bool
InFlowContext
()
const
{
return
!
m_flows
.
empty
();
}
bool
InBlockContext
()
const
{
return
m_flows
.
empty
();
}
in
t
GetFlowLevel
()
const
{
return
m_flows
.
size
();
}
std
::
size_
t
GetFlowLevel
()
const
{
return
m_flows
.
size
();
}
Token
::
TYPE
GetStartTokenFor
(
IndentMarker
::
INDENT_TYPE
type
)
const
;
IndentMarker
*
PushIndentTo
(
int
column
,
IndentMarker
::
INDENT_TYPE
type
);
...
...
@@ -83,13 +84,13 @@ class Scanner {
const
RegEx
&
GetValueRegex
()
const
;
struct
SimpleKey
{
SimpleKey
(
const
Mark
&
mark_
,
in
t
flowLevel_
);
SimpleKey
(
const
Mark
&
mark_
,
std
::
size_
t
flowLevel_
);
void
Validate
();
void
Invalidate
();
Mark
mark
;
in
t
flowLevel
;
std
::
size_
t
flowLevel
;
IndentMarker
*
pIndent
;
Token
*
pMapStart
,
*
pKey
;
};
...
...
src/simplekey.cpp
View file @
0c8a5393
...
...
@@ -4,7 +4,7 @@
namespace
YAML
{
struct
Mark
;
Scanner
::
SimpleKey
::
SimpleKey
(
const
Mark
&
mark_
,
in
t
flowLevel_
)
Scanner
::
SimpleKey
::
SimpleKey
(
const
Mark
&
mark_
,
std
::
size_
t
flowLevel_
)
:
mark
(
mark_
),
flowLevel
(
flowLevel_
),
pIndent
(
0
),
pMapStart
(
0
),
pKey
(
0
)
{}
void
Scanner
::
SimpleKey
::
Validate
()
{
...
...
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