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