X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.cpp;h=9ad0a557706b687d2a2775044c8fc55e6386019f;hb=242c55b17e6608b29a77ca17a5b677e202a3ca90;hp=36be492ac0724f1757fb56b6b2b5b9a825ff2981;hpb=77461a8c0e2b5686b04cf15f3a9333b215813992;p=builder.git diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 36be492..9ad0a55 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -11,9 +11,25 @@ Distributed under the LGPL using namespace std; using namespace Msp; -/** -Adds another BuildInfo to the end of this one. -*/ +namespace { + +/** Removes any duplicate entries from a list, leaving only the first one. The +order of other elements is preserved. O(n²) efficiency. */ +void unique(StringList &l) +{ + for(StringList::iterator i=l.begin(); i!=l.end(); ++i) + for(StringList::iterator j=i; j!=l.end();) + { + if(j!=i && *j==*i) + j=l.erase(j); + else + ++j; + } +} + +} + + void BuildInfo::add(const BuildInfo &bi) { cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end()); @@ -25,17 +41,14 @@ void BuildInfo::add(const BuildInfo &bi) warnings.insert(warnings.end(), bi.warnings.begin(), bi.warnings.end()); } -/** -Makes sure there are no duplicate entries in the lists. -*/ void BuildInfo::unique() { - unique(cflags); - unique(defines); - unique(incpath); - unique(ldflags); - unique(libpath); - unique(libs); + ::unique(cflags); + ::unique(defines); + ::unique(incpath); + ::unique(ldflags); + ::unique(libpath); + ::unique(libs); for(StringList::iterator i=warnings.begin(); i!=warnings.end(); ++i) { @@ -59,21 +72,6 @@ void BuildInfo::unique() } } -/** -Removes any duplicate entries from a list, leaving only the first one. The -order of other elements is preserved. O(n²) efficiency. -*/ -void BuildInfo::unique(StringList &l) -{ - for(StringList::iterator i=l.begin(); i!=l.end(); ++i) - for(StringList::iterator j=i; j!=l.end();) - { - if(j!=i && *j==*i) - j=l.erase(j); - else - ++j; - } -} BuildInfo::Loader::Loader(BuildInfo &bi): binfo(bi) @@ -87,4 +85,37 @@ BuildInfo::Loader::Loader(BuildInfo &bi): add("warning", &Loader::warning); } +void BuildInfo::Loader::cflag(const std::string &s) +{ + binfo.cflags.push_back(s); +} + +void BuildInfo::Loader::incpath(const std::string &s) +{ + binfo.incpath.push_back(s); +} + +void BuildInfo::Loader::define(const std::string &s) +{ + binfo.defines.push_back(s); +} +void BuildInfo::Loader::ldflag(const std::string &s) +{ + binfo.ldflags.push_back(s); +} + +void BuildInfo::Loader::libpath(const std::string &s) +{ + binfo.libpath.push_back(s); +} + +void BuildInfo::Loader::library(const std::string &s) +{ + binfo.libs.push_back(s); +} + +void BuildInfo::Loader::warning(const std::string &s) +{ + binfo.warnings.push_back(s); +}