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
a518d87c
Commit
a518d87c
authored
Mar 03, 2011
by
Jesse Beder
Browse files
Switched the emitter state's stack of groups to a ptr_stack
parent
27617ec2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
39 deletions
+27
-39
src/emitterstate.cpp
src/emitterstate.cpp
+10
-22
src/emitterstate.h
src/emitterstate.h
+16
-17
src/ptr_stack.h
src/ptr_stack.h
+1
-0
No files found.
src/emitterstate.cpp
View file @
a518d87c
...
...
@@ -25,18 +25,6 @@ namespace YAML
EmitterState
::~
EmitterState
()
{
while
(
!
m_groups
.
empty
())
_PopGroup
();
}
std
::
auto_ptr
<
EmitterState
::
Group
>
EmitterState
::
_PopGroup
()
{
if
(
m_groups
.
empty
())
return
std
::
auto_ptr
<
Group
>
(
0
);
std
::
auto_ptr
<
Group
>
pGroup
(
m_groups
.
top
());
m_groups
.
pop
();
return
pGroup
;
}
// SetLocalValue
...
...
@@ -57,10 +45,10 @@ namespace YAML
void
EmitterState
::
BeginGroup
(
GROUP_TYPE
type
)
{
unsigned
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
()
->
indent
);
unsigned
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
()
.
indent
);
m_curIndent
+=
lastIndent
;
std
::
auto_ptr
<
Group
>
pGroup
(
new
Group
(
type
));
std
::
auto_ptr
<
Group
>
pGroup
(
new
Group
(
type
));
// transfer settings (which last until this group is done)
pGroup
->
modifiedSettings
=
m_modifiedSettings
;
...
...
@@ -70,7 +58,7 @@ namespace YAML
pGroup
->
indent
=
GetIndent
();
pGroup
->
usingLongKey
=
(
GetMapKeyFormat
()
==
LongKey
?
true
:
false
);
m_groups
.
push
(
pGroup
.
release
()
);
m_groups
.
push
(
pGroup
);
}
void
EmitterState
::
EndGroup
(
GROUP_TYPE
type
)
...
...
@@ -80,13 +68,13 @@ namespace YAML
// get rid of the current group
{
std
::
auto_ptr
<
Group
>
pFinishedGroup
=
_PopGrou
p
();
std
::
auto_ptr
<
Group
>
pFinishedGroup
=
m_groups
.
po
p
();
if
(
pFinishedGroup
->
type
!=
type
)
return
SetError
(
ErrorMsg
::
UNMATCHED_GROUP_TAG
);
}
// reset old settings
unsigned
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
()
->
indent
);
unsigned
lastIndent
=
(
m_groups
.
empty
()
?
0
:
m_groups
.
top
()
.
indent
);
assert
(
m_curIndent
>=
lastIndent
);
m_curIndent
-=
lastIndent
;
...
...
@@ -100,7 +88,7 @@ namespace YAML
if
(
m_groups
.
empty
())
return
GT_NONE
;
return
m_groups
.
top
()
->
type
;
return
m_groups
.
top
()
.
type
;
}
FLOW_TYPE
EmitterState
::
GetCurGroupFlowType
()
const
...
...
@@ -108,26 +96,26 @@ namespace YAML
if
(
m_groups
.
empty
())
return
FT_NONE
;
return
(
m_groups
.
top
()
->
flow
==
Flow
?
FT_FLOW
:
FT_BLOCK
);
return
(
m_groups
.
top
()
.
flow
==
Flow
?
FT_FLOW
:
FT_BLOCK
);
}
bool
EmitterState
::
CurrentlyInLongKey
()
{
if
(
m_groups
.
empty
())
return
false
;
return
m_groups
.
top
()
->
usingLongKey
;
return
m_groups
.
top
()
.
usingLongKey
;
}
void
EmitterState
::
StartLongKey
()
{
if
(
!
m_groups
.
empty
())
m_groups
.
top
()
->
usingLongKey
=
true
;
m_groups
.
top
()
.
usingLongKey
=
true
;
}
void
EmitterState
::
StartSimpleKey
()
{
if
(
!
m_groups
.
empty
())
m_groups
.
top
()
->
usingLongKey
=
false
;
m_groups
.
top
()
.
usingLongKey
=
false
;
}
void
EmitterState
::
ClearModifiedSettings
()
...
...
src/emitterstate.h
View file @
a518d87c
...
...
@@ -6,6 +6,7 @@
#endif
#include "ptr_stack.h"
#include "setting.h"
#include "yaml-cpp/emittermanip.h"
#include <cassert>
...
...
@@ -155,19 +156,19 @@ namespace YAML
std
::
string
m_lastError
;
// other state
std
::
stack
<
EMITTER_STATE
>
m_stateStack
;
Setting
<
EMITTER_MANIP
>
m_charset
;
Setting
<
EMITTER_MANIP
>
m_strFmt
;
Setting
<
EMITTER_MANIP
>
m_boolFmt
;
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
<
EMITTER_MANIP
>
m_seqFmt
;
Setting
<
EMITTER_MANIP
>
m_mapFmt
;
Setting
<
EMITTER_MANIP
>
m_mapKeyFmt
;
std
::
stack
<
EMITTER_STATE
>
m_stateStack
;
Setting
<
EMITTER_MANIP
>
m_charset
;
Setting
<
EMITTER_MANIP
>
m_strFmt
;
Setting
<
EMITTER_MANIP
>
m_boolFmt
;
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
<
EMITTER_MANIP
>
m_seqFmt
;
Setting
<
EMITTER_MANIP
>
m_mapFmt
;
Setting
<
EMITTER_MANIP
>
m_mapKeyFmt
;
SettingChanges
m_modifiedSettings
;
SettingChanges
m_globalModifiedSettings
;
...
...
@@ -183,9 +184,7 @@ namespace YAML
SettingChanges
modifiedSettings
;
};
std
::
auto_ptr
<
Group
>
_PopGroup
();
std
::
stack
<
Group
*>
m_groups
;
ptr_stack
<
Group
>
m_groups
;
unsigned
m_curIndent
;
bool
m_requiresSoftSeparation
;
bool
m_requiresHardSeparation
;
...
...
src/ptr_stack.h
View file @
a518d87c
...
...
@@ -35,6 +35,7 @@ public:
return
t
;
}
T
&
top
()
{
return
*
m_data
.
back
();
}
const
T
&
top
()
const
{
return
*
m_data
.
back
();
}
private:
std
::
vector
<
T
*>
m_data
;
...
...
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