IShapeTableDefinition.hpp
1 #ifndef DM_IO_ISHAPE_TABLE_DEFINITION_HPP_INCLUDED
2 #define DM_IO_ISHAPE_TABLE_DEFINITION_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 #include "DM/config.hpp"
9 #include "DM/AutoLink.hpp" //enable autolink
10 
11 #include "DM/ColumnTypes.hpp"
12 #include "DM/IAddInfoLayout.hpp"
13 #include "DM/ObjectBase.hpp"
14 #include "DM/Handle.hpp"
15 
16 DM_NAMESPACE_BEGIN
17 
18 /// \brief Object storing a dbf table definition (for shape files)
19 class DM_API IShapeTableDefinition : public ObjectBase
20 {
21 public:
22  /// \brief create a dbf table definition based on a add info layout
23  static IShapeTableDefinition* New(const AddInfoLayoutHandle &layout);
24  static IShapeTableDefinition* New(unsigned count, const char **names, const ColumnType::Type *types, const unsigned *widths, const unsigned *decimals);
25 
26  static void translate(ColumnSemantic::Type sem, ColumnType::Type &dbfType, unsigned &dbfWidth, unsigned &dbfDecimals);
27  static void translate(ColumnType::Type ngType, unsigned size, ColumnType::Type &dbfType, unsigned &dbfWidth, unsigned &dbfDecimals);
28 protected:
29  virtual ~IShapeTableDefinition() {}
30 
31 public:
32  /// number of attributes/columns
33  virtual unsigned columns() const = 0;
34 
35  /// get name of attribute 'index'
36  virtual const char* name(unsigned index) const = 0;
37  /// get type of attribute 'index'
38  /** a shape file can contain following types:
39  - DM::ColumnType::cstr_ (fixed length c string)
40  - DM::ColumnType::int_ (4 byte, signed integer)
41  - DM::ColumnType::double_ (8 byte, real value)
42  - DM::ColumnType::bool_ (bit value)
43  */
44  virtual ColumnType::Type type(unsigned index) const = 0;
45 
46  /// length of string or number of digits for real and integeral number types
47  virtual unsigned width(unsigned index) const = 0;
48 
49  /// number of decimal places (only relevant for type DM::ColumnType::double_)
50  virtual unsigned decimales(unsigned index) const = 0;
51 
52 };
53 
55 
56 DM_NAMESPACE_END
57 
58 #endif //DM_IO_ISHAPE_TABLE_DEFINITION_HPP_INCLUDED