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
4a3f1801
Commit
4a3f1801
authored
Apr 09, 2015
by
Ludovic Courtès
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'header' class, for generic ALTA header parsing.
parent
53118958
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
45 deletions
+85
-45
sources/core/common.cpp
sources/core/common.cpp
+50
-1
sources/core/common.h
sources/core/common.h
+34
-0
sources/core/data_storage.cpp
sources/core/data_storage.cpp
+1
-44
No files found.
sources/core/common.cpp
View file @
4a3f1801
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2014 CNRS
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014
, 2015
Inria
This file is part of ALTA.
...
...
@@ -22,6 +22,9 @@
#include <unistd.h>
#endif
#include <iostream>
double
norm
(
const
vec
&
a
)
{
double
norm
=
0.0
;
...
...
@@ -179,3 +182,49 @@ unsigned int timer::current_time() const
return
(
unsigned
int
)
_time
.
tv_sec
;
#endif
}
header
::
header
(
std
::
istream
&
input
)
{
while
(
input
.
good
())
{
if
(
input
.
peek
()
==
'#'
)
{
input
.
get
();
// consume the hash sign
std
::
string
line
;
std
::
getline
(
input
,
line
);
std
::
stringstream
linestream
(
line
);
// Lines starting with '# ' are real comments and we ignore them.
// Others are key/value associations that we want to use.
if
(
linestream
.
peek
()
!=
' '
)
{
std
::
string
key
,
rest
;
linestream
>>
key
;
if
(
!
key
.
empty
())
{
if
(
key
==
"ALTA"
)
{
std
::
string
first
,
second
;
linestream
>>
first
>>
second
;
if
(
second
==
"HEADER"
)
{
if
(
first
==
"END"
)
break
;
else
_kind
=
first
;
}
}
else
{
getline
(
linestream
,
rest
);
_alist
[
key
]
=
rest
;
}
}
}
}
// The first non-comment line terminates the header.
else
break
;
}
}
sources/core/common.h
View file @
4a3f1801
...
...
@@ -29,6 +29,9 @@
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#ifdef OLD
/*! \brief A core implementation of a vector of double.
* \ingroup core
...
...
@@ -386,6 +389,37 @@ class timer
unsigned
int
_elapsed
;
};
// Reading the ALTA header of data and function files.
// Key/value association list.
class
header
{
public:
//! \brief Read the ALTA header on INPUT.
header
(
std
::
istream
&
input
);
//! \brief Return the type of this header--i.e., the "FOO" in
// "#ALTA FOO HEADER".
const
std
::
string
&
kind
()
const
{
return
_kind
;
}
//! \brief Return the value associated with KEY in this header.
const
std
::
string
&
operator
[](
const
std
::
string
&
key
)
{
return
_alist
[
key
];
}
protected:
std
::
string
_kind
;
std
::
map
<
std
::
string
,
std
::
string
>
_alist
;
};
// I/O error handling in user interfaces.
...
...
sources/core/data_storage.cpp
View file @
4a3f1801
...
...
@@ -19,48 +19,6 @@
# include <endian.h>
#endif
// Key/value association list.
typedef
std
::
map
<
std
::
string
,
std
::
string
>
alist
;
// Read the ALTA header on INPUT and fill in RESULT as a list of key/value
// pairs.
static
void
read_header
(
std
::
istream
&
input
,
alist
&
result
)
{
while
(
input
.
good
())
{
if
(
input
.
peek
()
==
'#'
)
{
input
.
get
();
// consume the hash sign
std
::
string
line
;
std
::
getline
(
input
,
line
);
std
::
stringstream
linestream
(
line
);
// Lines starting with '# ' are real comments and we ignore them.
// Others are key/value associations that we want to use.
if
(
linestream
.
peek
()
!=
' '
)
{
std
::
string
key
,
rest
;
linestream
>>
key
;
if
(
!
key
.
empty
())
{
getline
(
linestream
,
rest
);
if
(
key
==
"ALTA"
&&
rest
==
"END HEADER"
)
{
break
;
}
else
{
result
[
key
]
=
rest
;
}
}
}
}
// The first non-comment line terminates the header.
else
break
;
}
}
void
vertical_segment
::
load_data_from_text
(
std
::
istream
&
input
,
vertical_segment
&
result
,
const
arguments
&
args
)
...
...
@@ -71,8 +29,7 @@ void vertical_segment::load_data_from_text(std::istream& input,
result
.
_nX
=
0
;
result
.
_nY
=
0
;
std
::
vector
<
int
>
vs
;
int
current_vs
=
0
;
alist
header
;
read_header
(
input
,
header
);
header
header
(
input
);
{
std
::
stringstream
dim
(
header
[
"DIM"
]);
...
...
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