]> git.tdb.fi Git - builder.git/commitdiff
Disallow two components with the same name
authorMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 11:43:23 +0000 (13:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 14:11:05 +0000 (16:11 +0200)
source/lib/sourcepackage.cpp

index 09135921f51a99498974545e8c7c5e8e24d70718..34e8a1b6ec1c6009abc366960844981902a5262e 100644 (file)
@@ -219,6 +219,8 @@ void SourcePackage::Loader::feature(const string &n, const string &d)
 template<typename C, typename... Args>
 void SourcePackage::Loader::component(Args... args, const string &n)
 {
+       if(any_of(obj.components.begin(), obj.components.end(), [&n](const Component *c){ return c->get_name()==n; }))
+               throw key_error(n);
        C *comp = new C(obj, n, args...);
        load_sub(*comp);
        obj.components.push_back(comp);