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