Advanced Computing Platform for Theoretical Physics
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
Chen Xia
crdb
Commits
416d86a7
Commit
416d86a7
authored
Oct 13, 2020
by
Yu-Chen Ding
Browse files
port back to c++14
parent
c071bfde
Changes
7
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
416d86a7
build
deprecated
# Editor #
.*.sw?
*~
# Compiled source #
###################
*.com
...
...
CMakeLists.txt
View file @
416d86a7
...
...
@@ -4,18 +4,38 @@ if (POLICY CMP0048)
cmake_policy
(
SET CMP0048 NEW
)
endif
(
POLICY CMP0048
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g -Wall -Wextra"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O2"
)
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE Release
)
endif
()
message
(
">> CMAKE_BUILD_TYPE:
${
CMAKE_BUILD_TYPE
}
"
)
project
(
CRDB
VERSION 2.0.0
LANGUAGES CXX
DESCRIPTION
"C++ utility for analysis cosmic ray data"
)
set
(
CMAKE_CXX_STANDARD 20
)
find_package
(
ROOT
)
if
(
ROOT_FOUND
)
include_directories
(
"
${
ROOT_INCLUDE_DIRS
}
"
)
add_definitions
(
-DWITH_ROOT
)
MESSAGE
(
">> ROOT found"
)
if
(
NOT CMAKE_CXX_STANDARD
)
string
(
REGEX MATCH
"-std=(c|gnu)
\\
+
\\
+.."
ROOT_CXX_STANDARD
${
ROOT_CXX_FLAGS
}
)
string
(
REGEX MATCH
"..$"
ROOT_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
)
string
(
REPLACE 0x 11 ROOT_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
)
string
(
REPLACE 1y 14 ROOT_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
)
string
(
REPLACE 1z 17 ROOT_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
)
string
(
REPLACE 2a 20 ROOT_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
)
if
(
ROOT_CXX_STANDARD
)
MESSAGE
(
">> ROOT_CXX_STANDARD:
${
ROOT_CXX_STANDARD
}
"
)
set
(
CMAKE_CXX_STANDARD
${
ROOT_CXX_STANDARD
}
CACHE STRING
""
)
else
(
ROOT_CXX_STANDARD
)
set
(
CMAKE_CXX_STANDARD 14
)
endif
(
ROOT_CXX_STANDARD
)
endif
(
NOT CMAKE_CXX_STANDARD
)
MESSAGE
(
">> CMAKE_CXX_STANDARD:
${
CMAKE_CXX_STANDARD
}
"
)
else
(
ROOT_FOUND
)
MESSAGE
(
">> ROOT not found"
)
endif
(
ROOT_FOUND
)
...
...
src/CMakeLists.txt
View file @
416d86a7
...
...
@@ -8,7 +8,6 @@ target_include_directories(crdb PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties
(
crdb PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 20
PUBLIC_HEADER
"
${
CRDB_HEADERS
}
"
)
...
...
src/crdataset.cc
View file @
416d86a7
...
...
@@ -32,23 +32,14 @@ std::string parse_link(const std::string& hint) {
};
// namespace _CRDATASET
void
CRDataset
::
parse_file
(
const
std
::
string
&
filename
,
decltype
(
CRDataset
::
automatic
)
fileformat
)
{
// std::ifstream ifs;
// ifs.open(filename);
// if (!ifs) {
// throw std::runtime_error("cannot read '" + filename + '\'');
// }
void
CRDataset
::
parse_file
(
const
std
::
string
&
filename
)
{
enum
{
automatic
,
crd
,
usine
/* , galprop */
}
fileformat
=
automatic
;
_CRUTIL
::
FileParser
fp
(
filename
);
const
auto
&
line
=
fp
.
current_line
();
fp
.
next_line
(
fp
.
skip
::
empty
);
while
(
fp
)
{
// if (line.empty()) {
// ps.getline(ifs);
// continue;
// }
// determine fileformat
if
(
fileformat
==
automatic
)
{
...
...
@@ -58,7 +49,6 @@ void CRDataset::parse_file(const std::string& filename,
// } else if (line.substr(0, 20) == "# Format: USINE code") {
fileformat
=
usine
;
}
else
{
// undetermined, read next line
// ps.getline(ifs);
fp
.
next_line
(
fp
.
skip
::
empty
);
continue
;
}
...
...
@@ -305,7 +295,8 @@ std::shared_ptr<CRData> _CRDATASET::parse_data_usine(_CRUTIL::FileParser& fp) {
windows_str
+=
datimes
.
substr
(
i
+
18
,
10
);
windows_str
+=
datimes
.
substr
(
i
+
35
,
1
);
}
std
::
erase
(
windows_str
,
'/'
);
// -std=c++2a
// std::erase(windows_str, '/'); // -std=c++2a
std
::
remove
(
windows_str
.
begin
(),
windows_str
.
end
(),
'/'
);
data
.
time
=
windows_str
;
// TODO: parse windows
...
...
src/crdb.h
View file @
416d86a7
...
...
@@ -103,14 +103,7 @@ class CRData {
class
CRDataset
:
public
std
::
vector
<
std
::
shared_ptr
<
CRData
>>
{
// TODO: parse as construction
public:
enum
{
automatic
,
crd
,
usine
/* , galprop */
};
// public:
// const std::vector<std::shared_ptr<CRData>>& GetData() const { return *this; }
public:
void
parse_file
(
const
std
::
string
&
filename
,
decltype
(
automatic
)
fileformat
=
automatic
);
void
parse_file
(
const
std
::
string
&
filename
);
// void parse_remote(const std::string& url);
...
...
src/crutil.cc
View file @
416d86a7
#include "crutil.hh"
#include <istream>
#include <algorithm>
#include <string>
bool
_CRUTIL
::
is_substr_i
(
const
std
::
string
&
sup
,
const
std
::
string
&
sub
,
...
...
@@ -46,27 +47,8 @@ int _CRUTIL::strncasecmp(const char* s1, const char* s2, size_t n) {
return
0
;
}
// bool _CRUTIL::ParseState::getline(std::istream& is) {
// if (std::getline(is, line)) {
// ++line_number;
// // trim line
// line.erase(line.begin(),
// std::find_if(line.begin(), line.end(), [](unsigned char ch) {
// return !std::isspace(ch);
// }));
// line.erase(
// std::find_if(line.rbegin(), line.rend(),
// [](unsigned char ch) { return !std::isspace(ch); })
// .base(),
// line.end());
// return true;
// } else {
// return false;
// }
// }
_CRUTIL
::
FileParser
::
FileParser
(
const
std
::
string
&
filename
)
:
_line
(
""
),
_line_number
(
0
),
_filename
(
filename
),
std
::
ifstream
(
filename
)
{
:
std
::
ifstream
(
filename
),
_line
(
""
),
_filename
(
filename
),
_line_number
(
0
)
{
if
(
!
good
())
{
throw
std
::
runtime_error
(
"unable to read '"
+
filename
+
"'"
);
}
...
...
test/test_read.cc
View file @
416d86a7
...
...
@@ -6,6 +6,10 @@ int main(int argc, char* argv[]) {
CRDataset
ds
;
if
(
argc
!=
2
)
{
std
::
cerr
<<
argv
[
0
]
<<
" <data-file>"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
ds
.
parse_file
(
argv
[
1
]);
for
(
auto
pd
:
ds
)
{
...
...
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