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
5a2183f5
Commit
5a2183f5
authored
May 21, 2012
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed old emitter state machine
parent
41c2ddc0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
108 deletions
+4
-108
include/yaml-cpp/emitter.h
+0
-19
src/emitter.cpp
+0
-0
src/emitterstate.cpp
+1
-24
src/emitterstate.h
+3
-65
No files found.
include/yaml-cpp/emitter.h
View file @
5a2183f5
...
@@ -70,21 +70,11 @@ namespace YAML
...
@@ -70,21 +70,11 @@ namespace YAML
Emitter
&
WriteStreamable
(
T
value
);
Emitter
&
WriteStreamable
(
T
value
);
private
:
private
:
void
PreWriteIntegralType
(
std
::
stringstream
&
str
);
void
PreWriteStreamable
(
std
::
stringstream
&
str
);
void
PostWriteIntegralType
(
const
std
::
stringstream
&
str
);
void
PostWriteStreamable
(
const
std
::
stringstream
&
str
);
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
template
<
typename
T
>
void
SetStreamablePrecision
(
std
::
stringstream
&
)
{}
unsigned
GetFloatPrecision
()
const
;
unsigned
GetFloatPrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
unsigned
GetDoublePrecision
()
const
;
private
:
private
:
void
PreAtomicWrite
();
bool
GotoNextPreAtomicState
();
void
PostAtomicWrite
();
void
EmitSeparationIfNecessary
();
void
EmitBeginDoc
();
void
EmitBeginDoc
();
void
EmitEndDoc
();
void
EmitEndDoc
();
void
EmitBeginSeq
();
void
EmitBeginSeq
();
...
@@ -111,10 +101,6 @@ namespace YAML
...
@@ -111,10 +101,6 @@ namespace YAML
if
(
!
good
())
if
(
!
good
())
return
*
this
;
return
*
this
;
std
::
stringstream
str
;
PreWriteIntegralType
(
str
);
str
<<
value
;
PostWriteIntegralType
(
str
);
return
*
this
;
return
*
this
;
}
}
...
@@ -124,11 +110,6 @@ namespace YAML
...
@@ -124,11 +110,6 @@ namespace YAML
if
(
!
good
())
if
(
!
good
())
return
*
this
;
return
*
this
;
std
::
stringstream
str
;
PreWriteStreamable
(
str
);
SetStreamablePrecision
<
T
>
(
str
);
str
<<
value
;
PostWriteStreamable
(
str
);
return
*
this
;
return
*
this
;
}
}
...
...
src/emitter.cpp
View file @
5a2183f5
This diff is collapsed.
Click to expand it.
src/emitterstate.cpp
View file @
5a2183f5
...
@@ -4,11 +4,8 @@
...
@@ -4,11 +4,8 @@
namespace
YAML
namespace
YAML
{
{
EmitterState
::
EmitterState
()
:
m_isGood
(
true
),
m_curIndent
(
0
)
,
m_requiresSoftSeparation
(
false
),
m_requiresHardSeparation
(
false
)
EmitterState
::
EmitterState
()
:
m_isGood
(
true
),
m_curIndent
(
0
)
{
{
// start up
m_stateStack
.
push
(
ES_WAITING_FOR_DOC
);
// set default global manipulators
// set default global manipulators
m_charset
.
set
(
EmitNonAscii
);
m_charset
.
set
(
EmitNonAscii
);
m_strFmt
.
set
(
Auto
);
m_strFmt
.
set
(
Auto
);
...
@@ -59,7 +56,6 @@ namespace YAML
...
@@ -59,7 +56,6 @@ namespace YAML
// set up group
// set up group
pGroup
->
flow
=
GetFlowType
(
type
);
pGroup
->
flow
=
GetFlowType
(
type
);
pGroup
->
indent
=
GetIndent
();
pGroup
->
indent
=
GetIndent
();
pGroup
->
usingLongKey
=
(
GetMapKeyFormat
()
==
LongKey
?
true
:
false
);
m_groups
.
push
(
pGroup
);
m_groups
.
push
(
pGroup
);
}
}
...
@@ -101,25 +97,6 @@ namespace YAML
...
@@ -101,25 +97,6 @@ namespace YAML
return
(
m_groups
.
top
().
flow
==
Flow
?
FlowType
::
Flow
:
FlowType
::
Block
);
return
(
m_groups
.
top
().
flow
==
Flow
?
FlowType
::
Flow
:
FlowType
::
Block
);
}
}
bool
EmitterState
::
CurrentlyInLongKey
()
{
if
(
m_groups
.
empty
())
return
false
;
return
m_groups
.
top
().
usingLongKey
;
}
void
EmitterState
::
StartLongKey
()
{
if
(
!
m_groups
.
empty
())
m_groups
.
top
().
usingLongKey
=
true
;
}
void
EmitterState
::
StartSimpleKey
()
{
if
(
!
m_groups
.
empty
())
m_groups
.
top
().
usingLongKey
=
false
;
}
void
EmitterState
::
ClearModifiedSettings
()
void
EmitterState
::
ClearModifiedSettings
()
{
{
...
...
src/emitterstate.h
View file @
5a2183f5
...
@@ -20,46 +20,6 @@ namespace YAML
...
@@ -20,46 +20,6 @@ namespace YAML
struct
GroupType
{
enum
value
{
None
,
Seq
,
Map
};
};
struct
GroupType
{
enum
value
{
None
,
Seq
,
Map
};
};
struct
FlowType
{
enum
value
{
None
,
Flow
,
Block
};
};
struct
FlowType
{
enum
value
{
None
,
Flow
,
Block
};
};
enum
NODE_STATE
{
NS_START
,
NS_READY_FOR_ATOM
,
NS_END
};
enum
EMITTER_STATE
{
ES_WAITING_FOR_DOC
,
ES_WRITING_DOC
,
ES_DONE_WITH_DOC
,
// block seq
ES_WAITING_FOR_BLOCK_SEQ_ENTRY
,
ES_WRITING_BLOCK_SEQ_ENTRY
,
ES_DONE_WITH_BLOCK_SEQ_ENTRY
,
// flow seq
ES_WAITING_FOR_FLOW_SEQ_ENTRY
,
ES_WRITING_FLOW_SEQ_ENTRY
,
ES_DONE_WITH_FLOW_SEQ_ENTRY
,
// block map
ES_WAITING_FOR_BLOCK_MAP_ENTRY
,
ES_WAITING_FOR_BLOCK_MAP_KEY
,
ES_WRITING_BLOCK_MAP_KEY
,
ES_DONE_WITH_BLOCK_MAP_KEY
,
ES_WAITING_FOR_BLOCK_MAP_VALUE
,
ES_WRITING_BLOCK_MAP_VALUE
,
ES_DONE_WITH_BLOCK_MAP_VALUE
,
// flow map
ES_WAITING_FOR_FLOW_MAP_ENTRY
,
ES_WAITING_FOR_FLOW_MAP_KEY
,
ES_WRITING_FLOW_MAP_KEY
,
ES_DONE_WITH_FLOW_MAP_KEY
,
ES_WAITING_FOR_FLOW_MAP_VALUE
,
ES_WRITING_FLOW_MAP_VALUE
,
ES_DONE_WITH_FLOW_MAP_VALUE
};
class
EmitterState
class
EmitterState
{
{
public
:
public
:
...
@@ -71,14 +31,6 @@ namespace YAML
...
@@ -71,14 +31,6 @@ namespace YAML
const
std
::
string
GetLastError
()
const
{
return
m_lastError
;
}
const
std
::
string
GetLastError
()
const
{
return
m_lastError
;
}
void
SetError
(
const
std
::
string
&
error
)
{
m_isGood
=
false
;
m_lastError
=
error
;
}
void
SetError
(
const
std
::
string
&
error
)
{
m_isGood
=
false
;
m_lastError
=
error
;
}
// main state of the machine
EMITTER_STATE
GetCurState
()
const
{
return
m_stateStack
.
top
();
}
void
SwitchState
(
EMITTER_STATE
state
)
{
PopState
();
PushState
(
state
);
}
void
PushState
(
EMITTER_STATE
state
)
{
m_stateStack
.
push
(
state
);
}
void
PopState
()
{
m_stateStack
.
pop
();
}
void
SetLocalValue
(
EMITTER_MANIP
value
);
// group handling
// group handling
void
BeginGroup
(
GroupType
::
value
type
);
void
BeginGroup
(
GroupType
::
value
type
);
void
EndGroup
(
GroupType
::
value
type
);
void
EndGroup
(
GroupType
::
value
type
);
...
@@ -86,21 +38,12 @@ namespace YAML
...
@@ -86,21 +38,12 @@ namespace YAML
GroupType
::
value
GetCurGroupType
()
const
;
GroupType
::
value
GetCurGroupType
()
const
;
FlowType
::
value
GetCurGroupFlowType
()
const
;
FlowType
::
value
GetCurGroupFlowType
()
const
;
int
GetCurIndent
()
const
{
return
m_curIndent
;
}
int
GetCurIndent
()
const
{
return
m_curIndent
;
}
bool
CurrentlyInLongKey
();
void
StartLongKey
();
void
StartSimpleKey
();
bool
RequiresSoftSeparation
()
const
{
return
m_requiresSoftSeparation
;
}
bool
RequiresHardSeparation
()
const
{
return
m_requiresHardSeparation
;
}
void
RequireSoftSeparation
()
{
m_requiresSoftSeparation
=
true
;
}
void
RequireHardSeparation
()
{
m_requiresSoftSeparation
=
true
;
m_requiresHardSeparation
=
true
;
}
void
ForceHardSeparation
()
{
m_requiresSoftSeparation
=
false
;
}
void
UnsetSeparation
()
{
m_requiresSoftSeparation
=
false
;
m_requiresHardSeparation
=
false
;
}
void
ClearModifiedSettings
();
void
ClearModifiedSettings
();
// formatters
// formatters
void
SetLocalValue
(
EMITTER_MANIP
value
);
bool
SetOutputCharset
(
EMITTER_MANIP
value
,
FmtScope
::
value
scope
);
bool
SetOutputCharset
(
EMITTER_MANIP
value
,
FmtScope
::
value
scope
);
EMITTER_MANIP
GetOutputCharset
()
const
{
return
m_charset
.
get
();
}
EMITTER_MANIP
GetOutputCharset
()
const
{
return
m_charset
.
get
();
}
...
@@ -148,8 +91,6 @@ namespace YAML
...
@@ -148,8 +91,6 @@ namespace YAML
std
::
string
m_lastError
;
std
::
string
m_lastError
;
// other state
// other state
std
::
stack
<
EMITTER_STATE
>
m_stateStack
;
Setting
<
EMITTER_MANIP
>
m_charset
;
Setting
<
EMITTER_MANIP
>
m_charset
;
Setting
<
EMITTER_MANIP
>
m_strFmt
;
Setting
<
EMITTER_MANIP
>
m_strFmt
;
Setting
<
EMITTER_MANIP
>
m_boolFmt
;
Setting
<
EMITTER_MANIP
>
m_boolFmt
;
...
@@ -168,11 +109,10 @@ namespace YAML
...
@@ -168,11 +109,10 @@ namespace YAML
SettingChanges
m_globalModifiedSettings
;
SettingChanges
m_globalModifiedSettings
;
struct
Group
{
struct
Group
{
Group
(
GroupType
::
value
type_
)
:
type
(
type_
),
usingLongKey
(
false
),
indent
(
0
)
{}
Group
(
GroupType
::
value
type_
)
:
type
(
type_
),
indent
(
0
)
{}
GroupType
::
value
type
;
GroupType
::
value
type
;
EMITTER_MANIP
flow
;
EMITTER_MANIP
flow
;
bool
usingLongKey
;
int
indent
;
int
indent
;
SettingChanges
modifiedSettings
;
SettingChanges
modifiedSettings
;
...
@@ -180,8 +120,6 @@ namespace YAML
...
@@ -180,8 +120,6 @@ namespace YAML
ptr_stack
<
Group
>
m_groups
;
ptr_stack
<
Group
>
m_groups
;
unsigned
m_curIndent
;
unsigned
m_curIndent
;
bool
m_requiresSoftSeparation
;
bool
m_requiresHardSeparation
;
};
};
template
<
typename
T
>
template
<
typename
T
>
...
...
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