ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
E57Exception.h
Go to the documentation of this file.
1 /*
2  * Original work Copyright 2009 - 2010 Kevin Ackley (kackley@gwi.net)
3  * Modified work Copyright 2018 - 2020 Andy Maloney <asmaloney@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person or organization
6  * obtaining a copy of the software and accompanying documentation covered by
7  * this license (the "Software") to use, reproduce, display, distribute,
8  * execute, and transmit the Software, and to prepare derivative works of the
9  * Software, and to permit third-parties to whom the Software is furnished to
10  * do so, all subject to the following:
11  *
12  * The copyright notices in the Software and this entire statement, including
13  * the above license grant, this restriction and the following disclaimer,
14  * must be included in all copies of the Software, in whole or in part, and
15  * all derivative works of the Software, unless such copies or derivative
16  * works are solely in the form of machine-executable object code generated by
17  * a source language processor.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  */
27 
28 #pragma once
29 
30 #include <exception>
31 #include <iostream>
32 #include <string>
33 
34 #include "E57Export.h"
35 
36 namespace e57
37 {
39  enum ErrorCode
40  {
41  // N.B. *** When changing error strings here, remember to update the error
42  // strings in E57Exception.cpp ****
97  };
98 
99  class E57_DLL E57Exception : public std::exception
100  {
101  public:
102  void report( const char *reportingFileName = nullptr, int reportingLineNumber = 0,
103  const char *reportingFunctionName = nullptr, std::ostream &os = std::cout ) const;
104  ErrorCode errorCode() const;
105  std::string context() const;
106  const char *what() const noexcept override;
107 
108  // For debugging purposes:
109  const char *sourceFileName() const;
110  const char *sourceFunctionName() const;
111  int sourceLineNumber() const;
112 
115  E57Exception() = delete;
116  E57Exception( ErrorCode ecode, const std::string &context, const std::string &srcFileName = nullptr,
117  int srcLineNumber = 0, const char *srcFunctionName = nullptr );
118  ~E57Exception() noexcept override = default;
119 
120  protected:
121  ErrorCode errorCode_;
122  std::string context_;
123  std::string sourceFileName_;
124  const char *sourceFunctionName_;
125  int sourceLineNumber_;
127  };
128 
129  namespace Utilities
130  {
131  // Get latest version of ASTM standard supported, and library id string
132  E57_DLL void getVersions( int &astmMajor, int &astmMinor, std::string &libraryId );
133 
134  E57_DLL std::string errorCodeToString( ErrorCode ecode );
135  }
136 }
Object thrown by E57 API functions to communicate the conditions of an error.
Definition: E57Exception.h:100
ImGuiContext * context
Definition: Window.cpp:76
E57_DLL std::string errorCodeToString(ErrorCode ecode)
Get short string description of an E57 ErrorCode.
E57_DLL void getVersions(int &astmMajor, int &astmMinor, std::string &libraryId)
Get the version of ASTM E57 standard that the API implementation supports, and library id string.
ErrorCode
Numeric error identifiers used in E57Exception.
Definition: E57Exception.h:40
@ E57_ERROR_FILE_IS_READ_ONLY
can't modify read only file
Definition: E57Exception.h:60
@ E57_ERROR_TOO_MANY_READERS
too many open CompressedVectorReaders of an ImageFile
Definition: E57Exception.h:94
@ E57_ERROR_BUFFERS_NOT_COMPATIBLE
SourceDestBuffers not compatible with previously given ones.
Definition: E57Exception.h:92
@ E57_SUCCESS
operation was successful
Definition: E57Exception.h:43
@ E57_ERROR_CONVERSION_REQUIRED
conversion required to assign element value, but not requested
Definition: E57Exception.h:82
@ E57_ERROR_BUFFER_DUPLICATE_PATHNAME
duplicate pathname in CompressedVectorNode read/write
Definition: E57Exception.h:72
@ E57_ERROR_READ_FAILED
read() failed
Definition: E57Exception.h:64
@ E57_ERROR_INTERNAL
An unrecoverable inconsistent internal state was detected.
Definition: E57Exception.h:56
@ E57_ERROR_VALUE_OUT_OF_BOUNDS
element value out of min/max bounds
Definition: E57Exception.h:81
@ E57_ERROR_OPEN_FAILED
open() failed
Definition: E57Exception.h:62
@ E57_ERROR_BAD_NODE_DOWNCAST
bad downcast from Node to specific node type
Definition: E57Exception.h:85
@ E57_ERROR_SET_TWICE
attempted to set an existing child element to a new value
Definition: E57Exception.h:47
@ E57_ERROR_BAD_API_ARGUMENT
bad API function argument provided by user
Definition: E57Exception.h:59
@ E57_ERROR_BAD_FILE_SIGNATURE
file signature not "ASTM-E57"
Definition: E57Exception.h:73
@ E57_ERROR_WRITE_FAILED
write() failed
Definition: E57Exception.h:65
@ E57_ERROR_HOMOGENEOUS_VIOLATION
Definition: E57Exception.h:48
@ E57_ERROR_NO_BUFFER_FOR_ELEMENT
Definition: E57Exception.h:69
@ E57_ERROR_NODE_UNATTACHED
node is not yet attached to tree of ImageFile
Definition: E57Exception.h:88
@ E57_ERROR_BAD_PROTOTYPE
bad prototype in CompressedVectorNode
Definition: E57Exception.h:79
@ E57_ERROR_REAL64_TOO_LARGE
a 64 bit IEEE float was too large to store in a 32 bit IEEE float
Definition: E57Exception.h:53
@ E57_ERROR_XML_PARSER_INIT
XML parser failed to initialize.
Definition: E57Exception.h:76
@ E57_ERROR_BAD_CV_PACKET
a CompressedVector binary packet was bad
Definition: E57Exception.h:45
@ E57_ERROR_BAD_CHECKSUM
checksum mismatch, file is corrupted
Definition: E57Exception.h:61
@ E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS
a numerical index identifying a child was out of bounds
Definition: E57Exception.h:46
@ E57_ERROR_IMAGEFILE_NOT_OPEN
destImageFile is no longer open
Definition: E57Exception.h:91
@ E57_ERROR_BAD_XML_FORMAT
E57 primitive not encoded in XML correctly.
Definition: E57Exception.h:57
@ E57_ERROR_NOT_IMPLEMENTED
functionality not implemented
Definition: E57Exception.h:84
@ E57_ERROR_XML_PARSER
XML not well formed.
Definition: E57Exception.h:58
@ E57_ERROR_EXPECTING_NUMERIC
Expecting numeric representation in user's buffer, found ustring.
Definition: E57Exception.h:54
@ E57_ERROR_BUFFER_SIZE_MISMATCH
SourceDestBuffers not all same size.
Definition: E57Exception.h:71
@ E57_ERROR_BAD_CODECS
bad codecs in CompressedVectorNode
Definition: E57Exception.h:80
@ E57_ERROR_TOO_MANY_WRITERS
too many open CompressedVectorWriters of an ImageFile
Definition: E57Exception.h:93
@ E57_ERROR_BAD_FILE_LENGTH
size in file header not same as actual
Definition: E57Exception.h:75
@ E57_ERROR_ALREADY_HAS_PARENT
node already has a parent
Definition: E57Exception.h:89
@ E57_ERROR_UNKNOWN_FILE_VERSION
incompatible file version
Definition: E57Exception.h:74
@ E57_ERROR_INVARIANCE_VIOLATION
class invariance constraint violation in debug mode
Definition: E57Exception.h:96
@ E57_ERROR_READER_NOT_OPEN
CompressedVectorReader is no longer open.
Definition: E57Exception.h:87
@ E57_ERROR_VALUE_NOT_REPRESENTABLE
a value could not be represented in the requested type
Definition: E57Exception.h:50
@ E57_ERROR_BAD_CV_HEADER
a CompressedVector binary header was bad
Definition: E57Exception.h:44
@ E57_ERROR_CLOSE_FAILED
close() failed
Definition: E57Exception.h:63
@ E57_ERROR_BAD_CONFIGURATION
bad configuration string
Definition: E57Exception.h:95
@ E57_ERROR_DIFFERENT_DEST_IMAGEFILE
nodes were constructed with different destImageFiles
Definition: E57Exception.h:90
@ E57_ERROR_WRITER_NOT_OPEN
CompressedVectorWriter is no longer open.
Definition: E57Exception.h:86
@ E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE
Definition: E57Exception.h:51
@ E57_ERROR_BAD_BUFFER
bad SourceDestBuffer
Definition: E57Exception.h:68
@ E57_ERROR_BAD_PATH_NAME
E57 path name is not well formed.
Definition: E57Exception.h:83
@ E57_ERROR_EXPECTING_USTRING
Expecting string representation in user's buffer, found numeric.
Definition: E57Exception.h:55
@ E57_ERROR_DUPLICATE_NAMESPACE_PREFIX
namespace prefix already defined
Definition: E57Exception.h:77
@ E57_ERROR_LSEEK_FAILED
lseek() failed
Definition: E57Exception.h:66
@ E57_ERROR_PATH_UNDEFINED
E57 element path well formed but not defined.
Definition: E57Exception.h:67
@ E57_ERROR_DUPLICATE_NAMESPACE_URI
namespace URI already defined
Definition: E57Exception.h:78