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
ae41e58c
Commit
ae41e58c
authored
Jul 30, 2009
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for emitting and represeting null
parent
72919adf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
50 additions
and
0 deletions
+50
-0
include/conversion.h
+4
-0
include/emitter.h
+2
-0
include/null.h
+14
-0
src/conversion.cpp
+6
-0
src/emitter.cpp
+12
-0
src/node.cpp
+4
-0
src/null.cpp
+6
-0
yaml-reader/emittertests.cpp
+0
-0
yaml-reader/tests.cpp
+1
-0
yaml-reader/tests.h
+1
-0
No files found.
include/conversion.h
View file @
ae41e58c
...
...
@@ -4,6 +4,7 @@
#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#include "null.h"
#include <string>
#include <sstream>
...
...
@@ -38,6 +39,9 @@ namespace YAML
bool
Converter
<
bool
>::
Convert
(
const
std
::
string
&
input
,
bool
&
output
);
template
<>
bool
Converter
<
_Null
>::
Convert
(
const
std
::
string
&
input
,
_Null
&
output
);
template
<>
bool
Converter
<
std
::
wstring
>::
Convert
(
const
std
::
string
&
input
,
std
::
wstring
&
output
);
}
...
...
include/emitter.h
View file @
ae41e58c
...
...
@@ -6,6 +6,7 @@
#include "emittermanip.h"
#include "ostream.h"
#include "null.h"
#include <memory>
#include <string>
...
...
@@ -51,6 +52,7 @@ namespace YAML
Emitter
&
Write
(
const
_Alias
&
alias
);
Emitter
&
Write
(
const
_Anchor
&
anchor
);
Emitter
&
Write
(
const
_Comment
&
comment
);
Emitter
&
Write
(
const
_Null
&
null
);
private
:
enum
ATOMIC_TYPE
{
AT_SCALAR
,
AT_SEQ
,
AT_BLOCK_SEQ
,
AT_FLOW_SEQ
,
AT_MAP
,
AT_BLOCK_MAP
,
AT_FLOW_MAP
};
...
...
include/null.h
0 → 100644
View file @
ae41e58c
#pragma once
#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
namespace
YAML
{
struct
_Null
{};
extern
_Null
Null
;
}
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
\ No newline at end of file
src/conversion.cpp
View file @
ae41e58c
...
...
@@ -84,6 +84,12 @@ namespace YAML
}
template
<>
bool
Converter
<
_Null
>::
Convert
(
const
std
::
string
&
input
,
_Null
&
/*output*/
)
{
return
input
.
empty
()
||
input
==
"~"
||
input
==
"null"
||
input
==
"Null"
||
input
==
"NULL"
;
}
template
<>
bool
Converter
<
std
::
wstring
>::
Convert
(
const
std
::
string
&
input
,
std
::
wstring
&
output
)
{
output
.
clear
();
...
...
src/emitter.cpp
View file @
ae41e58c
...
...
@@ -666,4 +666,16 @@ namespace YAML
Utils
::
WriteComment
(
m_stream
,
comment
.
content
,
m_pState
->
GetPostCommentIndent
());
return
*
this
;
}
Emitter
&
Emitter
::
Write
(
const
_Null
&
/*null*/
)
{
if
(
!
good
())
return
*
this
;
PreAtomicWrite
();
EmitSeparationIfNecessary
();
m_stream
<<
"~"
;
PostAtomicWrite
();
return
*
this
;
}
}
src/node.cpp
View file @
ae41e58c
...
...
@@ -10,6 +10,7 @@
#include "aliascontent.h"
#include "iterpriv.h"
#include "emitter.h"
#include <stdexcept>
namespace
YAML
{
...
...
@@ -85,6 +86,9 @@ namespace YAML
m_pContent
=
new
Map
;
break
;
default
:
// std::stringstream str;
// str << TokenNames[pScanner->peek().type];
// throw std::runtime_error(str.str());
break
;
}
...
...
src/null.cpp
0 → 100644
View file @
ae41e58c
#include "null.h"
namespace
YAML
{
_Null
Null
;
}
yaml-reader/emittertests.cpp
View file @
ae41e58c
This diff is collapsed.
Click to expand it.
yaml-reader/tests.cpp
View file @
ae41e58c
...
...
@@ -351,6 +351,7 @@ namespace Test
RunEmitterTest
(
&
Emitter
::
Indentation
,
"indentation"
,
passed
);
RunEmitterTest
(
&
Emitter
::
SimpleGlobalSettings
,
"simple global settings"
,
passed
);
RunEmitterTest
(
&
Emitter
::
ComplexGlobalSettings
,
"complex global settings"
,
passed
);
RunEmitterTest
(
&
Emitter
::
Null
,
"null"
,
passed
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndSeq
,
"extra EndSeq"
,
passed
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndMap
,
"extra EndMap"
,
passed
);
...
...
yaml-reader/tests.h
View file @
ae41e58c
...
...
@@ -68,6 +68,7 @@ namespace Test {
void
Indentation
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredOutput
);
void
SimpleGlobalSettings
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredOutput
);
void
ComplexGlobalSettings
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredOutput
);
void
Null
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredOutput
);
// incorrect emitting
void
ExtraEndSeq
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredError
);
...
...
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