votca
2024.2-dev
Loading...
Searching...
No Matches
tools
include
votca
tools
lexical_cast.h
Go to the documentation of this file.
1
/*
2
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#ifndef VOTCA_TOOLS_LEXICAL_CAST_H
19
#define VOTCA_TOOLS_LEXICAL_CAST_H
20
21
// Standard includes
22
#include <stdexcept>
23
#include <string>
24
25
// Third party includes
26
#include <boost/lexical_cast.hpp>
27
28
namespace
votca
{
29
namespace
tools {
30
37
template
<
typename
Target,
typename
Source>
38
inline
Target
lexical_cast
(
const
Source &arg,
const
std::string &error) {
39
try
{
40
return
boost::lexical_cast<Target, Source>(arg);
41
}
catch
(std::exception &) {
42
throw
std::runtime_error(
"invalid type: "
+ error);
43
}
44
}
45
46
}
// namespace tools
47
}
// namespace votca
48
49
#endif
// VOTCA_TOOLS_LEXICAL_CAST_H
votca::tools::lexical_cast
Target lexical_cast(const Source &arg, const std::string &error)
Definition
lexical_cast.h:38
votca
base class for all analysis tools
Definition
basebead.h:33
Generated by
1.12.0