IImportAny.hpp
1 #ifndef DM_IO_IMPORT_ANY_HPP_INCLUDED
2 #define DM_IO_IMPORT_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/IImport.hpp"
14 
15 //boost
16 #include <boost/any.hpp>
17 
18 DM_NAMESPACE_BEGIN
19 
20 class DM_API IImportAny : public virtual IImport
21 {
22 public:
23  static IImportAny* New( const char *file, bool ascii, FilterHandle filter = FilterHandle(),
25  bool collectHdrContents = false, unsigned maxBulkPoints = 1000 );
26 
27 protected:
28  virtual ~IImportAny() {}
29 
30 public:
31  // ascii only
32  virtual void setColumnSeparators( const char *separators ) = 0;
33  virtual void setCommentInitiator( const char *commentInit ) = 0;
34  virtual void setDecimalSeparator( char decimalSeparator ) = 0;
35  virtual void skipWhiteSpace( bool skip ) = 0;
36  virtual void setHeaderLineCount( unsigned count ) = 0;
37 
38  // binary only
39  virtual void setHeaderBytes( unsigned count ) = 0;
40  virtual void setEndianness( Endianness::Type endian ) = 0;
41 
42  // ascii and binary
43  virtual void setHeaderText( const char *text ) = 0;
44  virtual void throwIfXYMissing( bool doThrow ) = 0;
45 
46  /// \name data block
47  /// specify the sequence of coordinates and attributes to be imported, and optionally, characters/bytes to be ignored. The order is important!
48  //@{
49  virtual void addCoordX( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
50  virtual void addCoordY( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
51  virtual void addCoordZ( ColumnType::Type externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
52 
53  // attrib: the attribute enum
54  // externalType: use that type for reading, then convert to attribute's internal type. default: same as internal type
55  // invalidValue: if specified, consider this value as invalid, generate no attribute. Must be of type externalType
56  //void addAttrib( unsigned colPos, ColumnType::Type externalType = ColumnType::count, const boost::any &invalidValue = boost::any() );
57  virtual void addAttrib( ColumnSemantic::Type attrib, ColumnType::Type externalType = ColumnType::count, const boost::any &invalidValue = boost::any(), const char* converterStr = 0 ) = 0;
58 
59  virtual void addAttrib( const char *name, ColumnType::Type internalType, ColumnType::Type externalType = ColumnType::count, const boost::any &invalidValue = boost::any(), const char * converterStr = 0 ) = 0;
60 
61  // ascii: skip count columns
62  // binary: skip count bytes
63  virtual void addSkip( unsigned count = 1 ) = 0;
64 
65  // ascii only: if present, store the rest of each line following the specified coordinates/attributes as a custom attribute with name 'attrName' of type string
66  virtual void storeRest( const char* attrName ) = 0;
67  //}@
68 
69 };
70 
72 
73 DM_NAMESPACE_END
74 
75 #endif //DM_IO_IMPORT_BASE_HPP_INCLUDED