]> git.tdb.fi Git - builder.git/blob - source/buildinfo.cpp
Add missing includes
[builder.git] / source / buildinfo.cpp
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <algorithm>
9 #include "buildinfo.h"
10
11 using namespace Msp;
12
13 /**
14 Adds another BuildInfo to the end of this one.
15 */
16 void BuildInfo::add(const BuildInfo &bi)
17 {
18         cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end());
19         defines.insert(defines.end(), bi.defines.begin(), bi.defines.end());
20         incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end());
21         ldflags.insert(ldflags.end(), bi.ldflags.begin(), bi.ldflags.end());
22         libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
23         libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
24 }
25
26 /**
27 Makes sure there are no duplicate entries in the lists.
28 */
29 void BuildInfo::unique()
30 {
31         unique(cflags);
32         unique(defines);
33         unique(incpath);
34         unique(ldflags);
35         unique(libpath);
36         unique(libs);
37 }
38
39 /**
40 Removes any duplicate entries from a list, leaving only the first one.  The
41 order of other elements is preserved.  O(n²) efficiency.
42 */
43 void BuildInfo::unique(StringList &l)
44 {
45         StringList l2;
46         for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
47                 if(find(l2.begin(), l2.end(), *i)==l2.end())
48                         l2.push_back(*i);
49         swap(l, l2);
50 }
51
52 BuildInfo::Loader::Loader(BuildInfo &bi):
53         binfo(bi)
54 {
55         add("cflag",   &Loader::cflag);
56         add("incpath", &Loader::incpath);
57         add("define",  &Loader::define);
58         add("ldflag",  &Loader::ldflag);
59         add("libpath", &Loader::libpath);
60         add("library", &Loader::library);
61 }
62
63