GISCup 2015
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
NewNodeAttrib.hpp
Go to the documentation of this file.
1 /* Copyright 2015 Martin Werner - <martin.werner@ifi.lmu.de>
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */#ifndef NewNodeAttrib_HPP_INC
16 #define NewNodeAttrib_HPP_INC
18 public:
19  double ID;
20 static inline std::string fieldname(size_t id) {
21 switch(id){
22  case 0: return std::string("ID");
23  default: return std::string("unknown fieldname");
24 }}; //fieldname
25 static bool assertCorrectFormat(DBFHandle hDBF)
26 {
27  size_t fields = DBFGetFieldCount(hDBF);
28  for (size_t i=0; i < fields; i++)
29  {
30  char name[20];
31  size_t type = DBFGetFieldInfo(hDBF,i,name, NULL, NULL);
32  if (fieldname(i) != name)
33  {
34  cout << "File DBF in wrong format" << endl;
35  cout << fieldname(i) << " expected. Found " << name << endl;
36  return false;
37  }
38  }
39  return true;
40 }
41 void readFromID(DBFHandle hDBF, size_t id) {
42  ID = _DBFReadDoubleAttribute(hDBF,id, 0);
43 };
44 void dump()
45 {
46  dump(cout);
47 }
48 template<typename stream> void dump(stream &o) {
49  o << "ID" <<":\t" << ID << std::endl;
50 };
51 };
52 #endif