52 std::vector<boost::filesystem::path>& douFiles,
53 std::vector<boost::filesystem::path>& domFiles)
55 std::set<boost::filesystem::path> thisRootFiles;
57 for (
const auto& root : roots)
59 thisRootFiles.clear();
60 boost::filesystem::path rootDir = boost::filesystem::canonical(root).string(std::codecvt_utf8_utf16<wchar_t>());
62 if (!boost::filesystem::exists(rootDir) || !boost::filesystem::is_directory(rootDir))
64 throw ParseError(
"Invalid directory path",
"The specified root directory does not exist.", root.string(), 8);
67 boost::filesystem::recursive_directory_iterator fileIt(rootDir), fileItEnd;
68 while (fileIt!=fileItEnd)
70 const boost::filesystem::path& fp=fileIt->path();
73 auto fileVec = boost::iequals(fp.extension().string(),
".dou") ? &douFiles : (boost::iequals(fp.extension().string(),
".dom") ? &domFiles :
nullptr);
74 if (fileVec !=
nullptr && boost::filesystem::is_regular_file(fp))
76 if (thisRootFiles.find(fp.filename()) != thisRootFiles.end())
78 std::ostringstream os;
79 os<<
"The directory '"<<root.string()<<
"' contains duplicated version of file '"<<fp.filename().string()<<
"'"<<std::endl;
80 throw ParseError(
"Duplicated dou/dom file", os.str(), fp.string(), 2);
82 thisRootFiles.insert(fp.filename());
83 fileVec->push_back(fp);
102 static inline std::shared_ptr<const TypeRepository>
ParseTypeDefinitions(
const std::vector<boost::filesystem::path>& roots)
104 std::vector<boost::filesystem::path> douFiles, domFiles;
106 return Internal::ParseTypeDefinitionsImpl(douFiles, domFiles);
static void GetFilesFromRootDirectories(const std::vector< boost::filesystem::path > &roots, std::vector< boost::filesystem::path > &douFiles, std::vector< boost::filesystem::path > &domFiles)
Extract all files from the given root folders separated as dou- and dom- files.
Definition TypeParser.h:51
static std::shared_ptr< const TypeRepository > ParseTypeDefinitions(const std::vector< boost::filesystem::path > &roots)
Will validate and parse a complete set of dou- and dom-files.
Definition TypeParser.h:102