-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathruntimepath.hpp
More file actions
71 lines (61 loc) · 2.08 KB
/
runtimepath.hpp
File metadata and controls
71 lines (61 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*****************************************************************************
*
* libdiffpy Complex Modeling Initiative
* (c) 2013 Brookhaven Science Associates,
* Brookhaven National Laboratory.
* All rights reserved.
*
* File coded by: Pavol Juhas
*
* See AUTHORS.txt for a list of people who contributed.
* See LICENSE.txt for license information.
*
******************************************************************************
*
* Functions for resolving paths to static data files at runtime.
*
*****************************************************************************/
#ifndef RUNTIMEPATH_HPP_INCLUDED
#define RUNTIMEPATH_HPP_INCLUDED
#include <string>
#include <vector>
#include <istream>
#include <stdexcept>
namespace diffpy {
namespace runtimepath {
/// Return full path to a data file included with DiffPy library.
///
/// The paths are looked up from the DIFFPYRUNTIME environment variable.
/// If DIFFPYRUNTIME does not exist, the paths are resolved as
/// (1) relative path of the datadir directory with respect to the libdir
/// directory at the installation time and if it does not exist as
/// (2) relative path of the runtime directory in a source tree
/// at the build time.
///
/// Throw runtime_error if the base directory cannot be found.
std::string datapath(const std::string& f);
/// Helper class for loading text data
class LineReader
{
public:
// constructor
LineReader();
// methods
bool isignored() const;
bool iscomment() const;
bool isblank() const;
size_t wcount() const;
std::runtime_error format_error(
const std::string& filename, const std::string& edetail);
// data
int lineno;
std::string commentmark;
std::string separator;
std::string line;
std::vector<std::string> words;
};
// non-member functions for the LineReader class
std::istream& operator>> (std::istream&, LineReader&);
} // namespace runtimepath
} // namespace diffpy
#endif // RUNTIMEPATH_HPP_INCLUDED