|
2 | 2 |
|
3 | 3 | #include "generation_configuration.h"
|
4 | 4 | #include <boost/assign.hpp>
|
| 5 | +#include <boost/filesystem.hpp> |
5 | 6 | #include <list>
|
| 7 | +#include <sstream> |
6 | 8 | #include <util/json.h>
|
7 | 9 |
|
8 | 10 | generation_configurationt::generation_configurationt(const jsont &json)
|
9 | 11 | {
|
10 | 12 | detected_entry_points_path =
|
11 | 13 | json[json_namest::detected_entry_points_path].value;
|
| 14 | + for(const jsont &element : json[json_namest::pattern_group].array) |
| 15 | + { |
| 16 | + pattern_group.emplace_back(element); |
| 17 | + } |
| 18 | + if(!pattern_group.empty()) |
| 19 | + { |
| 20 | + if(detected_entry_points_path.empty()) |
| 21 | + { |
| 22 | + std::stringstream error; |
| 23 | + error << "The configuration file contained pattern groups but not a " |
| 24 | + << json_namest::detected_entry_points_path << " element."; |
| 25 | + errors.push_back(error.str()); |
| 26 | + } |
| 27 | + else if(boost::filesystem::is_directory(detected_entry_points_path)) |
| 28 | + { |
| 29 | + std::stringstream error; |
| 30 | + error << "The output path '" << detected_entry_points_path |
| 31 | + << "' references an existing directory."; |
| 32 | + errors.push_back(error.str()); |
| 33 | + } |
| 34 | + } |
| 35 | + |
12 | 36 | collected_classes_info_path =
|
13 | 37 | json[json_namest::collected_classes_info_path].value;
|
14 |
| - collected_classes_path = json[json_namest::collected_classes_path].value; |
15 |
| - di_configuration_path = json[json_namest::di_configuration_path].value; |
| 38 | + if(collected_classes_info_path.empty()) |
| 39 | + { |
| 40 | + std::stringstream error; |
| 41 | + error << "The configuration file did not contain a " |
| 42 | + << json_namest::collected_classes_info_path << " element."; |
| 43 | + } |
| 44 | + else if(boost::filesystem::is_directory(collected_classes_info_path)) |
| 45 | + { |
| 46 | + std::stringstream error; |
| 47 | + error << "The output path '" << collected_classes_info_path |
| 48 | + << "' references an existing directory."; |
| 49 | + } |
16 | 50 |
|
17 |
| - for(const jsont &element : json[json_namest::pattern_group].array) |
| 51 | + collected_classes_path = json[json_namest::collected_classes_path].value; |
| 52 | + if(collected_classes_path.empty()) |
18 | 53 | {
|
19 |
| - pattern_group.emplace_back(element); |
| 54 | + std::stringstream error; |
| 55 | + error << "The configuration file did not contain a " |
| 56 | + << json_namest::collected_classes_path << " element."; |
| 57 | + errors.push_back(error.str()); |
| 58 | + } |
| 59 | + else if(!boost::filesystem::is_regular_file(collected_classes_path)) |
| 60 | + { |
| 61 | + std::stringstream error; |
| 62 | + error << "The input file '" << collected_classes_path |
| 63 | + << "' does not exist."; |
| 64 | + errors.push_back(error.str()); |
20 | 65 | }
|
| 66 | + |
| 67 | + di_configuration_path = json[json_namest::di_configuration_path].value; |
21 | 68 | }
|
0 commit comments