#include <packages_map.h>
Definition at line 13 of file packages_map.h.
◆ PackagesMap()
tonic::PackagesMap::PackagesMap |
( |
| ) |
|
◆ ~PackagesMap()
tonic::PackagesMap::~PackagesMap |
( |
| ) |
|
◆ Parse()
bool tonic::PackagesMap::Parse |
( |
const std::string & |
source, |
|
|
std::string * |
error |
|
) |
| |
Definition at line 24 of file packages_map.cc.
24 {
25 map_.clear();
27 for (
auto it =
source.begin(); it !=
end; ++it) {
28 const char c = *it;
29
30
31 if (isLineBreak(c))
32 continue;
33
34
35 if (c == '#') {
36 while (it !=
end && !isLineBreak(*it))
37 ++it;
38 continue;
39 }
40
41 if (c == ':') {
42 map_.clear();
43 *
error =
"Packages file contains a line that begins with ':'.";
44 return false;
45 }
46
47 auto package_name_begin = it;
48 auto package_name_end =
end;
49 bool found_separator = false;
50 for (; it !=
end; ++it) {
51 const char c = *it;
52 if (c == ':' && !found_separator) {
53 found_separator = true;
54 package_name_end = it;
55 continue;
56 }
57 if (isLineBreak(c))
58 break;
59 }
60
61 if (!found_separator) {
62 map_.clear();
63 *
error =
"Packages file contains non-comment line that lacks a ':'.";
64 return false;
65 }
66
67 std::string package_name(package_name_begin, package_name_end);
68 std::string package_path(package_name_end + 1, it);
69
70 auto result = map_.emplace(package_name, package_path);
72 map_.clear();
74 std::string("Packages file contains multiple entries for package '") +
75 package_name + "'.";
76 return false;
77 }
78 }
79
80 return true;
81}
const uint8_t uint32_t uint32_t GError ** error
◆ Resolve()
std::string tonic::PackagesMap::Resolve |
( |
const std::string & |
package_name | ) |
|
Definition at line 83 of file packages_map.cc.
83 {
84 return map_[package_name];
85}
The documentation for this class was generated from the following files: