Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alta
alta
Commits
de0e9344
Commit
de0e9344
authored
May 05, 2015
by
Ludovic Courtès
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
header: Constify operator[], and define the undefined value.
parent
6d52539b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
sources/core/common.cpp
sources/core/common.cpp
+2
-0
sources/core/common.h
sources/core/common.h
+17
-5
No files found.
sources/core/common.cpp
View file @
de0e9344
...
...
@@ -184,6 +184,8 @@ unsigned int timer::current_time() const
}
const
header
::
value
header
::
value
::
_undefined
(
""
);
header
::
header
(
std
::
istream
&
input
)
{
while
(
input
.
good
())
...
...
sources/core/common.h
View file @
de0e9344
...
...
@@ -401,9 +401,10 @@ class header
class
value
{
protected:
std
::
string
&
_value
;
const
std
::
string
&
_value
;
static
const
value
_undefined
;
public:
value
(
std
::
string
&
value
)
:
_value
(
value
)
{
};
value
(
const
std
::
string
&
value
)
:
_value
(
value
)
{
};
const
std
::
string
&
string
()
const
{
return
_value
;
}
operator
const
std
::
string
&
()
const
{
return
_value
;
}
operator
int
()
const
;
...
...
@@ -418,6 +419,12 @@ class header
std
::
pair
<
T
,
U
>
result
(
first
,
second
);
return
result
;
}
//! \brief Return true if this is the undefined value.
bool
is_undefined
()
const
{
return
this
==
&
_undefined
;
}
//! \brief Return the undefined value.
static
const
value
&
undefined
()
{
return
_undefined
;
}
};
//! \brief Read the ALTA header on INPUT.
...
...
@@ -431,10 +438,15 @@ class header
}
//! \brief Return the value associated with KEY in this header.
value
operator
[](
const
std
::
string
&
key
)
value
operator
[](
const
std
::
string
&
key
)
const
{
value
v
=
_alist
[
key
];
return
v
;
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
i
;
i
=
_alist
.
find
(
key
);
if
(
i
==
_alist
.
end
())
{
return
value
::
undefined
();
}
return
value
(
i
->
second
);
}
protected:
...
...
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