X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.cpp;h=5164ab08841c1ceed879f6fc5e4939770cd85cca;hb=bdc8b6638b486aa668b4a9c6c5cce5f6b5f18222;hp=766954623cc3679e0f063179a5fee870244e0da7;hpb=59ac0a44d6edf179c01604c6ced744873213f855;p=builder.git diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 7669546..5164ab0 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -1,8 +1,18 @@ -#include +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include #include "buildinfo.h" using namespace Msp; +/** +Adds another BuildInfo to the end of this one. +*/ void BuildInfo::add(const BuildInfo &bi) { cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end()); @@ -13,6 +23,9 @@ void BuildInfo::add(const BuildInfo &bi) libs.insert(libs.end(), bi.libs.begin(), bi.libs.end()); } +/** +Makes sure there are no duplicate entries in the lists. +*/ void BuildInfo::unique() { unique(cflags); @@ -23,11 +36,28 @@ void BuildInfo::unique() unique(libs); } -void BuildInfo::unique(InfoList &l) +/** +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) { - InfoList l2; - for(InfoList::iterator i=l.begin(); i!=l.end(); ++i) - if(!contains(l2, *i)) + StringList l2; + for(StringList::iterator i=l.begin(); i!=l.end(); ++i) + if(find(l2.begin(), l2.end(), *i)==l2.end()) l2.push_back(*i); swap(l, l2); } + +BuildInfo::Loader::Loader(BuildInfo &bi): + binfo(bi) +{ + add("cflag", &Loader::cflag); + add("incpath", &Loader::incpath); + add("define", &Loader::define); + add("ldflag", &Loader::ldflag); + add("libpath", &Loader::libpath); + add("library", &Loader::library); +} + +