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
020cd979
Commit
020cd979
authored
Sep 07, 2011
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up map searching by templated key
parent
f0174ca0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
31 deletions
+37
-31
include/yaml-cpp/value/detail/impl.h
+4
-4
include/yaml-cpp/value/detail/node.h
+7
-13
include/yaml-cpp/value/detail/node_data.h
+5
-5
include/yaml-cpp/value/impl.h
+16
-7
include/yaml-cpp/value/value.h
+3
-0
src/value/detail/node_data.cpp
+2
-2
No files found.
include/yaml-cpp/value/detail/impl.h
View file @
020cd979
...
...
@@ -15,13 +15,13 @@ namespace YAML
{
// indexing
template
<
typename
Key
>
inline
shared_node
node_data
::
operator
[](
const
Key
&
ke
y
)
const
inline
shared_node
node_data
::
get
(
const
Key
&
key
,
shared_memory_holder
pMemor
y
)
const
{
if
(
m_type
!=
ValueType
::
Map
)
return
shared_node
(
new
node
);
for
(
node_map
::
const_iterator
it
=
m_map
.
begin
();
it
!=
m_map
.
end
();
++
it
)
{
if
(
it
->
first
->
equals
(
ke
y
))
if
(
equals
(
it
->
first
,
key
,
pMemor
y
))
return
it
->
second
;
}
...
...
@@ -29,12 +29,12 @@ namespace YAML
}
template
<
typename
Key
>
inline
shared_node
node_data
::
operator
[](
const
Key
&
ke
y
)
inline
shared_node
node_data
::
get
(
const
Key
&
key
,
shared_memory_holder
pMemor
y
)
{
}
template
<
typename
Key
>
inline
bool
node_data
::
remove
(
const
Key
&
key
)
inline
bool
node_data
::
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
}
}
...
...
include/yaml-cpp/value/detail/node.h
View file @
020cd979
...
...
@@ -9,6 +9,7 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/node_data.h"
namespace
YAML
...
...
@@ -27,26 +28,19 @@ namespace YAML
void
set_type
(
ValueType
::
value
type
)
{
m_pData
->
set_type
(
type
);
}
void
set_null
()
{
m_pData
->
set_null
();
}
void
set_scalar
(
const
std
::
string
&
scalar
)
{
m_pData
->
set_scalar
(
scalar
);
}
template
<
typename
T
>
bool
equals
(
const
T
&
rhs
)
const
;
// indexing
template
<
typename
Key
>
shared_node
operator
[](
const
Key
&
key
)
const
{
return
(
static_cast
<
const
node_data
&>
(
*
m_pData
))[
key
]
;
}
template
<
typename
Key
>
shared_node
operator
[](
const
Key
&
key
)
{
return
(
*
m_pData
)[
key
]
;
}
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
)
{
return
m_pData
->
remove
(
ke
y
);
}
template
<
typename
Key
>
shared_node
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
get
(
key
,
pMemory
)
;
}
template
<
typename
Key
>
shared_node
get
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
get
(
key
,
pMemory
)
;
}
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
)
{
return
m_pData
->
remove
(
key
,
pMemor
y
);
}
shared_node
operator
[](
shared_node
pKey
)
const
{
return
(
static_cast
<
const
node_data
&>
(
*
m_pData
))[
pKey
]
;
}
shared_node
operator
[](
shared_node
pKey
)
{
return
(
*
m_pData
)[
pKey
]
;
}
shared_node
get
(
shared_node
pKey
)
const
{
return
static_cast
<
const
node_data
&>
(
*
m_pData
).
get
(
pKey
)
;
}
shared_node
get
(
shared_node
pKey
)
{
return
m_pData
->
get
(
pKey
)
;
}
bool
remove
(
shared_node
pKey
)
{
return
m_pData
->
remove
(
pKey
);
}
private
:
shared_node_data
m_pData
;
};
template
<
typename
T
>
inline
bool
node
::
equals
(
const
T
&
rhs
)
const
{
}
}
}
...
...
include/yaml-cpp/value/detail/node_data.h
View file @
020cd979
...
...
@@ -30,12 +30,12 @@ namespace YAML
const
std
::
string
scalar
()
const
{
return
m_scalar
;
}
// indexing
template
<
typename
Key
>
shared_node
operator
[](
const
Key
&
ke
y
)
const
;
template
<
typename
Key
>
shared_node
operator
[](
const
Key
&
ke
y
);
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
);
template
<
typename
Key
>
shared_node
get
(
const
Key
&
key
,
shared_memory_holder
pMemor
y
)
const
;
template
<
typename
Key
>
shared_node
get
(
const
Key
&
key
,
shared_memory_holder
pMemor
y
);
template
<
typename
Key
>
bool
remove
(
const
Key
&
key
,
shared_memory_holder
pMemory
);
shared_node
operator
[]
(
shared_node
pKey
)
const
;
shared_node
operator
[]
(
shared_node
pKey
);
shared_node
get
(
shared_node
pKey
)
const
;
shared_node
get
(
shared_node
pKey
);
bool
remove
(
shared_node
pKey
);
private
:
...
...
include/yaml-cpp/value/impl.h
View file @
020cd979
...
...
@@ -136,38 +136,38 @@ namespace YAML
template
<
typename
Key
>
inline
const
Value
Value
::
operator
[](
const
Key
&
key
)
const
{
detail
::
shared_node
pValue
=
(
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
))[
key
]
;
detail
::
shared_node
pValue
=
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
get
(
key
,
m_pMemory
)
;
return
Value
(
pValue
,
m_pMemory
);
}
template
<
typename
Key
>
inline
Value
Value
::
operator
[](
const
Key
&
key
)
{
detail
::
shared_node
pValue
=
(
*
m_pNode
)[
key
]
;
detail
::
shared_node
pValue
=
m_pNode
->
get
(
key
,
m_pMemory
)
;
return
Value
(
pValue
,
m_pMemory
);
}
template
<
typename
Key
>
inline
bool
Value
::
remove
(
const
Key
&
key
)
{
return
m_pNode
->
remove
(
key
);
return
m_pNode
->
remove
(
key
,
m_pMemory
);
}
inline
const
Value
Value
::
operator
[](
const
Value
&
key
)
const
{
detail
::
shared_node
pValue
=
(
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
))[
*
key
.
m_pNode
]
;
detail
::
shared_node
pValue
=
static_cast
<
const
detail
::
node
&>
(
*
m_pNode
).
get
(
key
.
m_pNode
)
;
return
Value
(
pValue
,
m_pMemory
);
}
inline
Value
Value
::
operator
[](
const
Value
&
key
)
{
detail
::
shared_node
pValue
=
(
*
m_pNode
)[
*
key
.
m_pNode
]
;
detail
::
shared_node
pValue
=
m_pNode
->
get
(
key
.
m_pNode
)
;
return
Value
(
pValue
,
m_pMemory
);
}
inline
bool
Value
::
remove
(
const
Value
&
key
)
{
return
m_pNode
->
remove
(
*
key
.
m_pNode
);
return
m_pNode
->
remove
(
key
.
m_pNode
);
}
inline
const
Value
Value
::
operator
[](
const
char
*
key
)
const
...
...
@@ -182,7 +182,7 @@ namespace YAML
inline
bool
Value
::
remove
(
const
char
*
key
)
{
return
m_pNode
->
remove
(
std
::
string
(
key
));
return
remove
(
std
::
string
(
key
));
}
inline
const
Value
Value
::
operator
[](
char
*
key
)
const
...
...
@@ -215,6 +215,15 @@ namespace YAML
{
return
false
;
}
template
<
typename
T
>
inline
bool
equals
(
detail
::
shared_node
pNode
,
const
T
&
rhs
,
detail
::
shared_memory_holder
pMemory
)
{
T
lhs
;
if
(
convert
(
Value
(
pNode
,
pMemory
),
lhs
))
return
lhs
==
rhs
;
return
false
;
}
}
#endif // VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
include/yaml-cpp/value/value.h
View file @
020cd979
...
...
@@ -61,6 +61,9 @@ namespace YAML
private
:
explicit
Value
(
detail
::
shared_node
pNode
,
detail
::
shared_memory_holder
pMemory
);
template
<
typename
T
>
friend
bool
equals
(
detail
::
shared_node
pNode
,
const
T
&
rhs
,
detail
::
shared_memory_holder
pMemory
);
template
<
typename
T
>
void
Assign
(
const
T
&
rhs
);
void
Assign
(
const
char
*
rhs
);
void
Assign
(
char
*
rhs
);
...
...
src/value/detail/node_data.cpp
View file @
020cd979
...
...
@@ -57,7 +57,7 @@ namespace YAML
}
// indexing
shared_node
node_data
::
operator
[]
(
shared_node
pKey
)
const
shared_node
node_data
::
get
(
shared_node
pKey
)
const
{
if
(
m_type
!=
ValueType
::
Map
)
return
shared_node
(
new
node
);
...
...
@@ -70,7 +70,7 @@ namespace YAML
return
shared_node
(
new
node
);
}
shared_node
node_data
::
operator
[]
(
shared_node
pKey
)
shared_node
node_data
::
get
(
shared_node
pKey
)
{
switch
(
m_type
)
{
case
ValueType
:
:
Undefined
:
...
...
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