IImportAny.hpp
1 #pragma once
2 
3 //DM
4 #include "DM/config.hpp"
5 #include "DM/AutoLink.hpp" //enable autolink
6 
7 #include "DM/ColumnTypes.hpp"
8 #include "DM/IO/IImport.hpp"
9 
10 //boost
11 #include <boost/any.hpp>
12 
13 DM_NAMESPACE_BEGIN
14 
15 /// \brief generic import for pretty much any ascii or binary original geometry data file
16 class DM_API IImportAny : public virtual IImport
17 {
18 public:
19  /// \brief creates new export object
20  /**
21  interface for exporting geometry objects for different file formats. if not specified the function estimates the file format
22  based on the file extension.
23  \param[in] file filename
24  \param[in] ascii flag if import should read file in ascii mode (true) of in binary mode (false)
25  \param[in] filter filter for subselecting/transforming objects during export
26  \param[in] control control object for retrieving export progress information
27  \param[in] collectHdrContents flag for explicitly collecting header information while exporting
28  \param[in] maxBulkPoints chunk size for bulk points being imported at once
29  */
30  static IImportAny* New( const char *file, bool ascii, FilterHandle filter = FilterHandle(),
32  bool collectHdrContents = false, unsigned maxBulkPoints = 1000 );
33 
34 protected:
35  virtual ~IImportAny() {}
36 
37 public:
38  // ascii only
39  virtual void setColumnSeparators( const char *separators ) = 0; ///< set seperator character (ascii only)
40  virtual void setCommentInitiator( const char *commentInit ) = 0; ///< set comment initiator (ascii only)
41  virtual void setDecimalSeparator( char decimalSeparator ) = 0; ///< set decimal seperator (ascii only)
42  virtual void skipWhiteSpace( bool skip ) = 0; ///< flag if white spaces should be skipped (ascii only)
43  virtual void setHeaderLineCount( unsigned count ) = 0; ///< set number of header lines that should be ignored (ascii only)
44 
45  // binary only
46  virtual void setHeaderBytes( unsigned count ) = 0; ///< set header bytes that should be ignored (binary only)
47  virtual void setEndianness( Endianness endian ) = 0; ///< set endianness type (binary only)
48 
49  // ascii and binary
50  virtual void setHeaderText( const char *text ) = 0; ///< set (optional) header text (ascii and binary)
51  virtual void throwIfXYMissing( bool doThrow ) = 0; ///< flag to throw exception if x and y coordinates are not set (ascii and binary)
52 
53  /// \name data block
54  /// specify the sequence of coordinates and attributes to be imported, and optionally, characters/bytes to be ignored. The order is important!
55  //@{
56  virtual void addCoordX( ColumnType externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
57  virtual void addCoordY( ColumnType externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
58  virtual void addCoordZ( ColumnType externalType = ColumnType::count, const char* converterStr = 0 ) = 0;
59 
60  // attrib: the attribute enum
61  // externalType: use that type for reading, then convert to attribute's internal type. default: same as internal type
62  // invalidValue: if specified, consider this value as invalid, generate no attribute. Must be of type externalType
63  //void addAttrib( unsigned colPos, ColumnType externalType = ColumnType::count, const boost::any &invalidValue = boost::any() );
64  virtual void addAttrib( ColumnSemantic attrib, ColumnType externalType = ColumnType::count, const boost::any &invalidValue = boost::any(), const char* converterStr = 0, const char *quoteStr = 0 ) = 0;
65 
66  virtual void addAttrib( const char *name, ColumnType internalType, ColumnType externalType = ColumnType::count, const boost::any &invalidValue = boost::any(), const char * converterStr = 0, const char *quoteStr = 0) = 0;
67 
68  /// skip count columns (ascii) / bytes (binary)
69  virtual void addSkip( unsigned count = 1 ) = 0;
70 
71  /// 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
72  virtual void storeRest( const char* attrName ) = 0;
73  //}@
74 
75 };
76 
78 
79 DM_NAMESPACE_END
ColumnSemantic
Pre-defined attributes (attributes with semantic)
Definition: ColumnTypes.hpp:38
base class for importing original geometry data file
Definition: M/c++_api/inc/DM/IO/IImport.hpp:42
generic import for pretty much any ascii or binary original geometry data file
Definition: IImportAny.hpp:16
ColumnType
Supported attribute type.
Definition: ColumnTypes.hpp:8
@ count
always last element
static IImport * New(const char *file, DataFormat format, FilterHandle filter=FilterHandle(), ControlObjectHandle control=ControlObjectHandle(), bool collectHdrContents=false, unsigned maxBulkPoints=1000, AddInfoLayoutHandle defaultLayout=AddInfoLayoutHandle())
creates new import object