IExportAny.hpp
1 #ifndef DM_IO_EXPORT_ANY_HPP_INCLUDED
2 #define DM_IO_EXPORT_ANY_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 //DM
9 #include "DM/config.hpp"
10 #include "DM/AutoLink.hpp" //enable autolink
11 
12 #include "DM/ColumnTypes.hpp"
13 #include "DM/IO/IExport.hpp"
14 
15 //boost
16 #include <boost/any.hpp>
17 
18 DM_NAMESPACE_BEGIN
19 
20 class DM_API IExportAny : public virtual IExport
21 {
22 public:
23  static IExportAny* New( const char *file, bool ascii, FilterHandle filter = FilterHandle(),
25  bool collectHdrContents = false, double invalidHeight = DBL_MAX );
26 
27 protected:
28  virtual ~IExportAny() {}
29 
30 public:
31  // ascii only
32  virtual void setColumnSeparator( char separator ) = 0;
33  virtual void setDecimalSeparator( char decimalSeparator ) = 0;
34 
35  // binary only
36  virtual void setEndianness( Endianness::Type endian ) = 0;
37 
38  virtual void setHeader( const char* text ) = 0;
39 
40  /// \name data block
41  /// specify the sequence of coordinates and attributes to be imported, and optionally, characters/bytes to be ignored. Order matters!
42  //@{
43  virtual void addCoordX( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0, int width = -1, int precision = -1, bool alignRight = true ) = 0;
44  virtual void addCoordY( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0, int width = -1, int precision = -1, bool alignRight = true ) = 0;
45  virtual void addCoordZ( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0, int width = -1, int precision = -1, bool alignRight = true ) = 0;
46 
47  // (possibly) fast access to predefined attributes using enum
48  // attrib: the attribute, e.g. eCOL_SIGMA_X
49  // externalType: convert the attribute value to that type during export
50  // Default: use the internal data type of attrib
51  // invalidValue: export that value in case attrib is not defined in the layout of the current point, of if it is null (not set).
52  // Default: the default-constructed (zero-) value for externalType.
53  // Must be of type externalType.
54  // width, precision, alignRight: relevant for export to ascii-files only.
55  virtual void addAttrib( ColumnSemantic::Type attrib, ColumnType::Type externalType = ColumnType::count, const boost::any &invalidValue = boost::any(), const char* converterStr = 0,
56  int width = -1, int precision = -1, bool alignRight = true ) = 0;
57 
58  // not-so-fast access based on attribute name, which is the only alternative for the export of custom attributes.
59  // Must specify an external type (the same for all points, while the internal type may differ between the attribute layouts of different points)
60  virtual void addAttrib( const char *name, ColumnType::Type externalType, const boost::any &invalidValue = boost::any(), const char* converterStr = 0,
61  int width = -1, int precision = -1, bool alignRight = true ) = 0;
62 
63  // Export a column/memory block of constant value at this point.
64  virtual void addFill( const boost::any &value ) = 0;
65  //}@
66 
67 };
68 
70 
71 DM_NAMESPACE_END
72 
73 #endif //DM_IO_EXPORT_ANY_HPP_INCLUDED