2 /// \file a_codsection.cc
3 /// COD structure for the ALX file parser
7 Copyright (C) 2010, Nicolas VIVIEN
8 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
27 #include "a_codsection.h"
34 std::string
trim(const std::string
&str
) {
40 const int len
= str
.size();
43 for (i
=0; (((str
[i
]==' ') || (str
[i
]=='\t') || (str
[i
]=='\r') || (str
[i
]=='\n')) && (i
<len
)); i
++);
47 for (i
=len
-1; (((str
[i
]==' ') || (str
[i
]=='\t') || (str
[i
]=='\r') || (str
[i
]=='\n')) && (i
>=0)); i
--);
50 s
= str
.substr(start
, end
-start
);
61 CODSection::CODSection(void)
67 CODSection::CODSection(const xmlpp::SaxParser::AttributeList
& attrs
)
71 for (xmlpp::SaxParser::AttributeList::const_iterator iter
= attrs
.begin(); iter
!= attrs
.end(); ++iter
) {
72 std::string
attribut(iter
->name
);
73 std::string
value(iter
->value
);
81 CODSection::~CODSection(void)
87 void CODSection::SetID(const std::string
& id
)
93 void CODSection::SetName(const std::string
& name
)
95 this->name
= trim(name
);
99 void CODSection::SetDescription(const std::string
& description
)
101 this->description
= trim(description
);
105 void CODSection::SetVersion(const std::string
& version
)
107 this->version
= trim(version
);
111 void CODSection::SetVendor(const std::string
& vendor
)
113 this->vendor
= trim(vendor
);
117 void CODSection::SetCopyright(const std::string
& copyright
)
119 this->copyright
= trim(copyright
);
123 void CODSection::SetDirectory(const std::string
& directory
)
125 this->directory
= trim(directory
);
129 void CODSection::SetRequired(const std::string
& required
)
131 std::string s
= trim(required
);
140 void CODSection::AddFiles(const std::string
& files
)
143 std::istringstream
iss(files
);
145 while( std::getline(iss
, file
) ) {
148 if (file
.length() > 0)
154 void CODSection::AddFile(const std::string
& file
)
156 codfiles
.push_back(file
);