From f9ebe2d1e920df001be2dd543a63677f8728f53d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 8 Mar 2018 16:50:59 +0200 Subject: Handle command line project/packages discovery --- bdep/utility.hxx | 60 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'bdep/utility.hxx') diff --git a/bdep/utility.hxx b/bdep/utility.hxx index 48f168f..8bca172 100644 --- a/bdep/utility.hxx +++ b/bdep/utility.hxx @@ -5,11 +5,12 @@ #ifndef BDEP_UTILITY_HXX #define BDEP_UTILITY_HXX -#include // make_shared() -#include // to_string() -#include // move(), forward(), declval(), make_pair() -#include // assert() -#include // make_move_iterator() +#include // make_shared() +#include // to_string() +#include // move(), forward(), declval(), make_pair() +#include // assert() +#include // make_move_iterator() +#include // find(), find_if() #include @@ -31,6 +32,9 @@ namespace bdep using std::make_move_iterator; using std::to_string; + using std::find; + using std::find_if; + // // using butl::casecmp; @@ -46,10 +50,21 @@ namespace bdep // Empty string and path. // - extern const string empty_string; - extern const path empty_path; + extern const string empty_string; + extern const path empty_path; extern const dir_path empty_dir_path; + // Widely-used paths. + // + extern const path manifest_file; // manifest + extern const path packages_file; // packages.manifest + extern const path configurations_file; // configurations.manifest + + // Directory extracted from argv[0] (i.e., this process' recall directory) + // or empty if there is none. Can be used as a search fallback. + // + extern dir_path exec_dir; + // Filesystem. // bool @@ -70,10 +85,35 @@ namespace bdep void rm (const path&, uint16_t verbosity = 3); - // Directory extracted from argv[0] (i.e., this process' recall directory) - // or empty if there is none. Can be used as a search fallback. + // Manifest parsing and serialization. // - extern dir_path exec_dir; + // For parsing, if path is '-', then read from stdin. + // + template + T + parse_manifest (const path&, + const char* what, + bool ignore_unknown = false); + + template + T + parse_manifest (istream&, + const string& name, + const char* what, + bool ignore_unknown = false); + + template + void + serialize_manifest (const T&, const path&, const char* what); + + template + void + serialize_manifest (const T&, + ostream&, + const string& name, + const char* what); } +#include + #endif // BDEP_UTILITY_HXX -- cgit v1.1