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
ff1a8fc5
Commit
ff1a8fc5
authored
Sep 09, 2011
by
Jesse Beder
Browse files
Started writing new iterators
parent
7bbf712c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
8 deletions
+87
-8
include/yaml-cpp/value.h
include/yaml-cpp/value.h
+1
-0
include/yaml-cpp/value/detail/node.h
include/yaml-cpp/value/detail/node.h
+10
-0
include/yaml-cpp/value/detail/node_data.h
include/yaml-cpp/value/detail/node_data.h
+11
-0
include/yaml-cpp/value/detail/node_ref.h
include/yaml-cpp/value/detail/node_ref.h
+10
-0
include/yaml-cpp/value/impl.h
include/yaml-cpp/value/impl.h
+6
-5
include/yaml-cpp/value/iterator.h
include/yaml-cpp/value/iterator.h
+3
-2
include/yaml-cpp/value/value.h
include/yaml-cpp/value/value.h
+3
-1
src/value/detail/node_data.cpp
src/value/detail/node_data.cpp
+43
-0
No files found.
include/yaml-cpp/value.h
View file @
ff1a8fc5
...
...
@@ -9,6 +9,7 @@
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/impl.h"
#include "yaml-cpp/value/convert.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/detail/impl.h"
#endif // VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/value/detail/node.h
View file @
ff1a8fc5
...
...
@@ -33,6 +33,16 @@ namespace YAML
void
set_null
()
{
m_pRef
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pRef
->
set_scalar
(
scalar
);
}
// size/iterator
std
::
size_t
size
()
const
{
return
m_pRef
->
size
();
}
const_iterator
begin
(
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
begin
(
pMemory
);
}
iterator
begin
(
shared_memory_holder
pMemory
)
{
return
m_pRef
->
begin
(
pMemory
);
}
const_iterator
end
(
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_ref
&>
(
*
m_pRef
).
end
(
pMemory
);
}
iterator
end
(
shared_memory_holder
pMemory
)
{
return
m_pRef
->
end
(
pMemory
);
}
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
m_pRef
->
append
(
node
,
pMemory
);
}
// indexing
...
...
include/yaml-cpp/value/detail/node_data.h
View file @
ff1a8fc5
...
...
@@ -7,6 +7,7 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include <boost/utility.hpp>
...
...
@@ -30,6 +31,16 @@ namespace YAML
ValueType
::
value
type
()
const
{
return
m_isDefined
?
m_type
:
ValueType
::
Undefined
;
}
const
std
::
string
&
scalar
()
const
{
return
m_scalar
;
}
// size/iterator
std
::
size_t
size
()
const
;
const_iterator
begin
(
shared_memory_holder
pMemory
)
const
;
iterator
begin
(
shared_memory_holder
pMemory
);
const_iterator
end
(
shared_memory_holder
pMemory
)
const
;
iterator
end
(
shared_memory_holder
pMemory
);
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
);
// indexing
...
...
include/yaml-cpp/value/detail/node_ref.h
View file @
ff1a8fc5
...
...
@@ -30,6 +30,16 @@ namespace YAML
void
set_null
()
{
ensure_data_exists
();
m_pData
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
ensure_data_exists
();
m_pData
->
set_scalar
(
scalar
);
}
// size/iterator
std
::
size_t
size
()
const
{
return
m_pData
?
m_pData
->
size
()
:
0
;
}
const_iterator
begin
(
shared_memory_holder
pMemory
)
const
{
return
m_pData
?
static_cast
<
const
node_data
&>
(
*
m_pData
).
begin
(
pMemory
)
:
const_iterator
();
}
iterator
begin
(
shared_memory_holder
pMemory
)
{
return
m_pData
?
m_pData
->
begin
(
pMemory
)
:
iterator
();
}
const_iterator
end
(
shared_memory_holder
pMemory
)
const
{
return
m_pData
?
static_cast
<
const
node_data
&>
(
*
m_pData
).
end
(
pMemory
)
:
const_iterator
();
}
iterator
end
(
shared_memory_holder
pMemory
)
{
return
m_pData
?
m_pData
->
end
(
pMemory
)
:
iterator
();
}
// sequence
void
append
(
node
&
node
,
shared_memory_holder
pMemory
)
{
ensure_data_exists
();
m_pData
->
append
(
node
,
pMemory
);
}
// indexing
...
...
include/yaml-cpp/value/impl.h
View file @
ff1a8fc5
...
...
@@ -7,6 +7,7 @@
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include <string>
...
...
@@ -127,27 +128,27 @@ namespace YAML
// size/iterator
inline
std
::
size_t
Value
::
size
()
const
{
return
0
;
return
m_pNode
->
size
()
;
}
inline
const_iterator
Value
::
begin
()
const
{
return
const_iterat
or
(
);
return
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
begin
(
m_pMem
or
y
);
}
inline
iterator
Value
::
begin
()
{
return
iterat
or
(
);
return
m_pNode
->
begin
(
m_pMem
or
y
);
}
inline
const_iterator
Value
::
end
()
const
{
return
const_iterat
or
(
);
return
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
end
(
m_pMem
or
y
);
}
inline
iterator
Value
::
end
()
{
return
iterat
or
(
);
return
m_pNode
->
end
(
m_pMem
or
y
);
}
// sequence
...
...
include/yaml-cpp/value/iterator.h
View file @
ff1a8fc5
...
...
@@ -7,11 +7,12 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/detail/iterator.h"
namespace
YAML
{
struct
iterator
{};
struct
const_iterator
{};
class
iterator
:
public
detail
::
iterator_base
<
detail
::
iterator_value
,
detail
::
node_seq_iterator
,
detail
::
node_map_iterator
>
{};
class
const_iterator
:
public
detail
::
iterator_base
<
const
detail
::
iterator_value
,
detail
::
node_seq_const_iterator
,
detail
::
node_map_const_iterator
>
{};
}
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/value/value.h
View file @
ff1a8fc5
...
...
@@ -7,13 +7,15 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include <stdexcept>
namespace
YAML
{
class
iterator
;
class
const_iterator
;
class
Value
{
public:
...
...
src/value/detail/node_data.cpp
View file @
ff1a8fc5
...
...
@@ -60,6 +60,49 @@ namespace YAML
m_scalar
=
scalar
;
}
// size/iterator
std
::
size_t
node_data
::
size
()
const
{
return
0
;
}
const_iterator
node_data
::
begin
(
shared_memory_holder
pMemory
)
const
{
switch
(
m_type
)
{
case
ValueType
::
Sequence
:
return
const_iterator
(
pMemory
,
m_sequence
.
begin
());
case
ValueType
::
Map
:
return
const_iterator
(
pMemory
,
m_map
.
begin
());
default:
return
const_iterator
();
}
}
iterator
node_data
::
begin
(
shared_memory_holder
pMemory
)
{
switch
(
m_type
)
{
case
ValueType
::
Sequence
:
return
iterator
(
pMemory
,
m_sequence
.
begin
());
case
ValueType
::
Map
:
return
iterator
(
pMemory
,
m_map
.
begin
());
default:
return
iterator
();
}
}
const_iterator
node_data
::
end
(
shared_memory_holder
pMemory
)
const
{
switch
(
m_type
)
{
case
ValueType
::
Sequence
:
return
const_iterator
(
pMemory
,
m_sequence
.
end
());
case
ValueType
::
Map
:
return
const_iterator
(
pMemory
,
m_map
.
end
());
default:
return
const_iterator
();
}
}
iterator
node_data
::
end
(
shared_memory_holder
pMemory
)
{
switch
(
m_type
)
{
case
ValueType
::
Sequence
:
return
iterator
(
pMemory
,
m_sequence
.
end
());
case
ValueType
::
Map
:
return
iterator
(
pMemory
,
m_map
.
end
());
default:
return
iterator
();
}
}
// sequence
void
node_data
::
append
(
node
&
node
,
shared_memory_holder
/* pMemory */
)
{
if
(
m_type
!=
ValueType
::
Sequence
)
...
...
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