diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-02 11:06:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-02 11:06:35 +0200 |
commit | 0c1ea060f7417ffc52cababd74278ea9d6047114 (patch) | |
tree | 4759bd1823c549381dd53efc5b5738ab2fd1ce42 /libbutl/b.cxx | |
parent | 8dd3964adbaccb1286d67d1b3ba63e47f545e65f (diff) |
Add version_string, list of modules to b_info() result
Also only attempt to parse the string version to standard version if the
version modules is loaded.
Diffstat (limited to 'libbutl/b.cxx')
-rw-r--r-- | libbutl/b.cxx | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/libbutl/b.cxx b/libbutl/b.cxx index e1caa4c..c55496c 100644 --- a/libbutl/b.cxx +++ b/libbutl/b.cxx @@ -20,6 +20,7 @@ #include <ios> // ios::failure #include <utility> // move() #include <sstream> +#include <algorithm> #endif // Other includes. @@ -156,16 +157,7 @@ namespace butl } else if (l.compare (0, 9, "version: ") == 0) { - string v (l, 9); - if (!v.empty ()) - try - { - r.version = standard_version (v, standard_version::allow_stub); - } - catch (const invalid_argument& e) - { - bad_value ("version '" + v + "': " + e.what ()); - } + r.version_string = string (l, 9); } else if (l.compare (0, 9, "summary: ") == 0) { @@ -232,12 +224,37 @@ namespace butl for (size_t b (0), e (0); next_word (v, b, e); ) r.meta_operations.push_back (string (v, b, e - b)); } + else if (l.compare (0, 9, "modules: ") == 0) + { + string v (l, 9); + for (size_t b (0), e (0); next_word (v, b, e); ) + r.modules.push_back (string (v, b, e - b)); + } } is.close (); // Detect errors. if (pr.wait ()) + { + // Parse version string to standard version if the project loaded + // the version module. + // + const auto& ms (r.modules); + if (find (ms.begin (), ms.end (), "version") != ms.end ()) + { + try + { + r.version = standard_version (r.version_string, + standard_version::allow_stub); + } + catch (const invalid_argument& e) + { + bad_value ("version '" + r.version_string + "': " + e.what ()); + } + } + return r; + } } // Note that ios::failure inherits from std::runtime_error, so this // catch-clause must go last. |