Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
6f94f954
Commit
6f94f954
authored
Nov 06, 2009
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overloaded more integral types for emitting
parent
90fd24d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
include/emitter.h
+26
-1
src/emitter.cpp
+7
-11
No files found.
include/emitter.h
View file @
6f94f954
...
@@ -46,7 +46,12 @@ namespace YAML
...
@@ -46,7 +46,12 @@ namespace YAML
// overloads of write
// overloads of write
Emitter
&
Write
(
const
std
::
string
&
str
);
Emitter
&
Write
(
const
std
::
string
&
str
);
Emitter
&
Write
(
const
char
*
str
);
Emitter
&
Write
(
const
char
*
str
);
Emitter
&
Write
(
int
i
);
Emitter
&
Write
(
int
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
unsigned
int
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
short
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
unsigned
short
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
long
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
unsigned
long
value
)
{
return
WriteIntegralType
(
value
);
}
Emitter
&
Write
(
bool
b
);
Emitter
&
Write
(
bool
b
);
Emitter
&
Write
(
float
f
);
Emitter
&
Write
(
float
f
);
Emitter
&
Write
(
double
d
);
Emitter
&
Write
(
double
d
);
...
@@ -57,6 +62,13 @@ namespace YAML
...
@@ -57,6 +62,13 @@ namespace YAML
Emitter
&
Write
(
const
_Null
&
null
);
Emitter
&
Write
(
const
_Null
&
null
);
private
:
private
:
void
PreWriteIntegralType
(
std
::
stringstream
&
str
);
void
PostWriteIntegralType
(
const
std
::
stringstream
&
str
);
template
<
typename
T
>
Emitter
&
WriteIntegralType
(
T
value
);
private
:
enum
ATOMIC_TYPE
{
AT_SCALAR
,
AT_SEQ
,
AT_BLOCK_SEQ
,
AT_FLOW_SEQ
,
AT_MAP
,
AT_BLOCK_MAP
,
AT_FLOW_MAP
};
enum
ATOMIC_TYPE
{
AT_SCALAR
,
AT_SEQ
,
AT_BLOCK_SEQ
,
AT_FLOW_SEQ
,
AT_MAP
,
AT_BLOCK_MAP
,
AT_FLOW_MAP
};
void
PreAtomicWrite
();
void
PreAtomicWrite
();
...
@@ -76,6 +88,19 @@ namespace YAML
...
@@ -76,6 +88,19 @@ namespace YAML
std
::
auto_ptr
<
EmitterState
>
m_pState
;
std
::
auto_ptr
<
EmitterState
>
m_pState
;
};
};
template
<
typename
T
>
inline
Emitter
&
Emitter
::
WriteIntegralType
(
T
value
)
{
if
(
!
good
())
return
*
this
;
std
::
stringstream
str
;
PreWriteIntegralType
(
str
);
str
<<
value
;
PostWriteIntegralType
(
str
);
return
*
this
;
}
// overloads of insertion
// overloads of insertion
template
<
typename
T
>
template
<
typename
T
>
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
T
v
)
{
inline
Emitter
&
operator
<<
(
Emitter
&
emitter
,
T
v
)
{
...
...
src/emitter.cpp
View file @
6f94f954
...
@@ -556,17 +556,13 @@ namespace YAML
...
@@ -556,17 +556,13 @@ namespace YAML
return
Write
(
std
::
string
(
str
));
return
Write
(
std
::
string
(
str
));
}
}
Emitter
&
Emitter
::
Write
(
int
i
)
void
Emitter
::
PreWriteIntegralType
(
std
::
stringstream
&
str
)
{
{
if
(
!
good
())
return
*
this
;
PreAtomicWrite
();
PreAtomicWrite
();
EmitSeparationIfNecessary
();
EmitSeparationIfNecessary
();
EMITTER_MANIP
intFmt
=
m_pState
->
GetIntFormat
();
EMITTER_MANIP
intFmt
=
m_pState
->
GetIntFormat
();
std
::
stringstream
str
;
switch
(
intFmt
)
{
switch
(
intFmt
)
{
case
Dec
:
case
Dec
:
str
<<
std
::
dec
;
str
<<
std
::
dec
;
...
@@ -574,18 +570,18 @@ namespace YAML
...
@@ -574,18 +570,18 @@ namespace YAML
case
Hex
:
case
Hex
:
str
<<
std
::
hex
;
str
<<
std
::
hex
;
break
;
break
;
case
Oct
:
case
Oct
:
str
<<
std
::
oct
;
str
<<
std
::
oct
;
break
;
break
;
default
:
default
:
assert
(
false
);
assert
(
false
);
}
}
}
str
<<
i
;
void
Emitter
::
PostWriteIntegralType
(
const
std
::
stringstream
&
str
)
{
m_stream
<<
str
.
str
();
m_stream
<<
str
.
str
();
PostAtomicWrite
();
PostAtomicWrite
();
return
*
this
;
}
}
Emitter
&
Emitter
::
Write
(
bool
b
)
Emitter
&
Emitter
::
Write
(
bool
b
)
...
...
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