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