Skip to content

Commit 34e83fc

Browse files
authored
Use clang-format (asmaloney#32)
I don't love the constructor and initializer lists, but that's a clang-format limitation.
1 parent 14f6a67 commit 34e83fc

30 files changed

+10589
-8609
lines changed

.clang-format

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# libE57Format
2+
# Options are listed here:
3+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
4+
---
5+
AccessModifierOffset: -3
6+
AlignAfterOpenBracket: Align
7+
AlignConsecutiveAssignments: false
8+
AlignConsecutiveDeclarations: false
9+
AlignEscapedNewlines: Right
10+
AlignOperands: true
11+
AlignTrailingComments: true
12+
AllowAllArgumentsOnNextLine: true
13+
AllowAllConstructorInitializersOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: true
15+
AllowShortBlocksOnASingleLine: false
16+
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortFunctionsOnASingleLine: None
18+
AllowShortLambdasOnASingleLine: All
19+
AllowShortIfStatementsOnASingleLine: Never
20+
AllowShortLoopsOnASingleLine: false
21+
AlwaysBreakAfterDefinitionReturnType: None
22+
AlwaysBreakAfterReturnType: None
23+
AlwaysBreakBeforeMultilineStrings: false
24+
AlwaysBreakTemplateDeclarations: MultiLine
25+
BinPackArguments: true
26+
BinPackParameters: true
27+
BraceWrapping:
28+
AfterCaseLabel: true
29+
AfterClass: true
30+
AfterControlStatement: true
31+
AfterEnum: true
32+
AfterFunction: true
33+
AfterNamespace: true
34+
AfterStruct: true
35+
AfterUnion: true
36+
AfterExternBlock: true
37+
BeforeCatch: true
38+
BeforeElse: true
39+
IndentBraces: false
40+
SplitEmptyFunction: true
41+
SplitEmptyRecord: true
42+
SplitEmptyNamespace: true
43+
BreakBeforeBinaryOperators: None
44+
BreakBeforeBraces: Custom
45+
BreakBeforeInheritanceComma: false
46+
BreakInheritanceList: BeforeColon
47+
BreakBeforeTernaryOperators: true
48+
BreakConstructorInitializersBeforeComma: false
49+
BreakConstructorInitializers: AfterColon
50+
BreakStringLiterals: true
51+
ColumnLimit: 120
52+
CommentPragmas: '^ IWYU pragma:'
53+
CompactNamespaces: false
54+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
55+
ConstructorInitializerIndentWidth: 3
56+
ContinuationIndentWidth: 3
57+
Cpp11BracedListStyle: false
58+
DerivePointerAlignment: false
59+
FixNamespaceComments: false
60+
IncludeBlocks: Preserve
61+
IncludeCategories:
62+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
63+
Priority: 2
64+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
65+
Priority: 3
66+
- Regex: '.*'
67+
Priority: 1
68+
IncludeIsMainRegex: '(Test)?$'
69+
IndentCaseLabels: true
70+
IndentPPDirectives: None
71+
IndentWidth: 3
72+
IndentWrappedFunctionNames: true
73+
KeepEmptyLinesAtTheStartOfBlocks: true
74+
Language: Cpp
75+
MaxEmptyLinesToKeep: 1
76+
NamespaceIndentation: All
77+
PenaltyBreakAssignment: 2
78+
PenaltyBreakBeforeFirstCallParameter: 19
79+
PenaltyBreakComment: 300
80+
PenaltyBreakFirstLessLess: 120
81+
PenaltyBreakString: 1000
82+
PenaltyBreakTemplateDeclaration: 10
83+
PenaltyExcessCharacter: 1000000
84+
PenaltyReturnTypeOnItsOwnLine: 1000
85+
PointerAlignment: Right
86+
ReflowComments: true
87+
SortIncludes: true
88+
SortUsingDeclarations: true
89+
SpaceAfterCStyleCast: false
90+
SpaceAfterLogicalNot: false
91+
SpaceAfterTemplateKeyword: true
92+
SpaceBeforeAssignmentOperators: true
93+
SpaceBeforeCpp11BracedList: false
94+
SpaceBeforeCtorInitializerColon: true
95+
SpaceBeforeInheritanceColon: true
96+
SpaceBeforeParens: ControlStatements
97+
SpaceBeforeRangeBasedForLoopColon: true
98+
SpaceInEmptyParentheses: false
99+
SpacesBeforeTrailingComments: 1
100+
SpacesInAngles: false
101+
SpacesInContainerLiterals: true
102+
SpacesInCStyleCastParentheses: false
103+
SpacesInParentheses: true
104+
SpacesInSquareBrackets: false
105+
Standard: Cpp11
106+
TabWidth: 3
107+
UseTab: Never
108+
...

.clang-format-ignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern/*

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [asmaloney]

include/E57Exception.h

+87-84
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#ifndef E57EXCEPTION_H
2-
#define E57EXCEPTION_H
3-
41
/*
52
* Copyright 2009 - 2010 Kevin Ackley ([email protected])
63
*
@@ -27,104 +24,110 @@
2724
* DEALINGS IN THE SOFTWARE.
2825
*/
2926

27+
#pragma once
28+
3029
#include <exception>
3130
#include <iostream>
3231
#include <string>
3332

34-
namespace e57 {
35-
36-
//! @brief Numeric error identifiers used in E57Exception
37-
enum ErrorCode {
38-
// N.B. *** When changing error strings here, remember to update the error strings in E57Exception.cpp ****
39-
E57_SUCCESS = 0, //!< operation was successful
40-
E57_ERROR_BAD_CV_HEADER = 1, //!< a CompressedVector binary header was bad
41-
E57_ERROR_BAD_CV_PACKET = 2, //!< a CompressedVector binary packet was bad
42-
E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS = 3, //!< a numerical index identifying a child was out of bounds
43-
E57_ERROR_SET_TWICE = 4, //!< attempted to set an existing child element to a new value
44-
E57_ERROR_HOMOGENEOUS_VIOLATION = 5, //!< attempted to add an E57 Element that would have made the children of a homogenous Vector have different types
45-
E57_ERROR_VALUE_NOT_REPRESENTABLE = 6, //!< a value could not be represented in the requested type
46-
E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE = 7, //!< after scaling the result could not be represented in the requested type
47-
E57_ERROR_REAL64_TOO_LARGE = 8, //!< a 64 bit IEEE float was too large to store in a 32 bit IEEE float
48-
E57_ERROR_EXPECTING_NUMERIC = 9, //!< Expecting numeric representation in user's buffer, found ustring
49-
E57_ERROR_EXPECTING_USTRING = 10, //!< Expecting string representation in user's buffer, found numeric
50-
E57_ERROR_INTERNAL = 11, //!< An unrecoverable inconsistent internal state was detected
51-
E57_ERROR_BAD_XML_FORMAT = 12, //!< E57 primitive not encoded in XML correctly
52-
E57_ERROR_XML_PARSER = 13, //!< XML not well formed
53-
E57_ERROR_BAD_API_ARGUMENT = 14, //!< bad API function argument provided by user
54-
E57_ERROR_FILE_IS_READ_ONLY = 15, //!< can't modify read only file
55-
E57_ERROR_BAD_CHECKSUM = 16, //!< checksum mismatch, file is corrupted
56-
E57_ERROR_OPEN_FAILED = 17, //!< open() failed
57-
E57_ERROR_CLOSE_FAILED = 18, //!< close() failed
58-
E57_ERROR_READ_FAILED = 19, //!< read() failed
59-
E57_ERROR_WRITE_FAILED = 20, //!< write() failed
60-
E57_ERROR_LSEEK_FAILED = 21, //!< lseek() failed
61-
E57_ERROR_PATH_UNDEFINED = 22, //!< E57 element path well formed but not defined
62-
E57_ERROR_BAD_BUFFER = 23, //!< bad SourceDestBuffer
63-
E57_ERROR_NO_BUFFER_FOR_ELEMENT = 24, //!< no buffer specified for an element in CompressedVectorNode during write
64-
E57_ERROR_BUFFER_SIZE_MISMATCH = 25, //!< SourceDestBuffers not all same size
65-
E57_ERROR_BUFFER_DUPLICATE_PATHNAME = 26, //!< duplicate pathname in CompressedVectorNode read/write
66-
E57_ERROR_BAD_FILE_SIGNATURE = 27, //!< file signature not "ASTM-E57"
67-
E57_ERROR_UNKNOWN_FILE_VERSION = 28, //!< incompatible file version
68-
E57_ERROR_BAD_FILE_LENGTH = 29, //!< size in file header not same as actual
69-
E57_ERROR_XML_PARSER_INIT = 30, //!< XML parser failed to initialize
70-
E57_ERROR_DUPLICATE_NAMESPACE_PREFIX = 31, //!< namespace prefix already defined
71-
E57_ERROR_DUPLICATE_NAMESPACE_URI = 32, //!< namespace URI already defined
72-
E57_ERROR_BAD_PROTOTYPE = 33, //!< bad prototype in CompressedVectorNode
73-
E57_ERROR_BAD_CODECS = 34, //!< bad codecs in CompressedVectorNode
74-
E57_ERROR_VALUE_OUT_OF_BOUNDS = 35, //!< element value out of min/max bounds
75-
E57_ERROR_CONVERSION_REQUIRED = 36, //!< conversion required to assign element value, but not requested
76-
E57_ERROR_BAD_PATH_NAME = 37, //!< E57 path name is not well formed
77-
E57_ERROR_NOT_IMPLEMENTED = 38, //!< functionality not implemented
78-
E57_ERROR_BAD_NODE_DOWNCAST = 39, //!< bad downcast from Node to specific node type
79-
E57_ERROR_WRITER_NOT_OPEN = 40, //!< CompressedVectorWriter is no longer open
80-
E57_ERROR_READER_NOT_OPEN = 41, //!< CompressedVectorReader is no longer open
81-
E57_ERROR_NODE_UNATTACHED = 42, //!< node is not yet attached to tree of ImageFile
82-
E57_ERROR_ALREADY_HAS_PARENT = 43, //!< node already has a parent
83-
E57_ERROR_DIFFERENT_DEST_IMAGEFILE = 44, //!< nodes were constructed with different destImageFiles
84-
E57_ERROR_IMAGEFILE_NOT_OPEN = 45, //!< destImageFile is no longer open
85-
E57_ERROR_BUFFERS_NOT_COMPATIBLE = 46, //!< SourceDestBuffers not compatible with previously given ones
86-
E57_ERROR_TOO_MANY_WRITERS = 47, //!< too many open CompressedVectorWriters of an ImageFile
87-
E57_ERROR_TOO_MANY_READERS = 48, //!< too many open CompressedVectorReaders of an ImageFile
88-
E57_ERROR_BAD_CONFIGURATION = 49, //!< bad configuration string
89-
E57_ERROR_INVARIANCE_VIOLATION = 50 //!< class invariance constraint violation in debug mode
90-
};
91-
92-
class E57Exception : public std::exception
33+
namespace e57
9334
{
35+
//! @brief Numeric error identifiers used in E57Exception
36+
enum ErrorCode
37+
{
38+
// N.B. *** When changing error strings here, remember to update the error
39+
// strings in E57Exception.cpp ****
40+
E57_SUCCESS = 0, //!< operation was successful
41+
E57_ERROR_BAD_CV_HEADER = 1, //!< a CompressedVector binary header was bad
42+
E57_ERROR_BAD_CV_PACKET = 2, //!< a CompressedVector binary packet was bad
43+
E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS = 3, //!< a numerical index identifying a child was out of bounds
44+
E57_ERROR_SET_TWICE = 4, //!< attempted to set an existing child element to a new value
45+
E57_ERROR_HOMOGENEOUS_VIOLATION = 5, //!< attempted to add an E57 Element that would have made the children
46+
//!< of a homogenous Vector have different types
47+
E57_ERROR_VALUE_NOT_REPRESENTABLE = 6, //!< a value could not be represented in the requested type
48+
E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE = 7, //!< after scaling the result could not be represented in the
49+
//!< requested type
50+
E57_ERROR_REAL64_TOO_LARGE = 8, //!< a 64 bit IEEE float was too large to store in a 32 bit IEEE float
51+
E57_ERROR_EXPECTING_NUMERIC = 9, //!< Expecting numeric representation in user's buffer, found ustring
52+
E57_ERROR_EXPECTING_USTRING = 10, //!< Expecting string representation in user's buffer, found numeric
53+
E57_ERROR_INTERNAL = 11, //!< An unrecoverable inconsistent internal state was detected
54+
E57_ERROR_BAD_XML_FORMAT = 12, //!< E57 primitive not encoded in XML correctly
55+
E57_ERROR_XML_PARSER = 13, //!< XML not well formed
56+
E57_ERROR_BAD_API_ARGUMENT = 14, //!< bad API function argument provided by user
57+
E57_ERROR_FILE_IS_READ_ONLY = 15, //!< can't modify read only file
58+
E57_ERROR_BAD_CHECKSUM = 16, //!< checksum mismatch, file is corrupted
59+
E57_ERROR_OPEN_FAILED = 17, //!< open() failed
60+
E57_ERROR_CLOSE_FAILED = 18, //!< close() failed
61+
E57_ERROR_READ_FAILED = 19, //!< read() failed
62+
E57_ERROR_WRITE_FAILED = 20, //!< write() failed
63+
E57_ERROR_LSEEK_FAILED = 21, //!< lseek() failed
64+
E57_ERROR_PATH_UNDEFINED = 22, //!< E57 element path well formed but not defined
65+
E57_ERROR_BAD_BUFFER = 23, //!< bad SourceDestBuffer
66+
E57_ERROR_NO_BUFFER_FOR_ELEMENT = 24, //!< no buffer specified for an element in CompressedVectorNode during
67+
//!< write
68+
E57_ERROR_BUFFER_SIZE_MISMATCH = 25, //!< SourceDestBuffers not all same size
69+
E57_ERROR_BUFFER_DUPLICATE_PATHNAME = 26, //!< duplicate pathname in CompressedVectorNode read/write
70+
E57_ERROR_BAD_FILE_SIGNATURE = 27, //!< file signature not "ASTM-E57"
71+
E57_ERROR_UNKNOWN_FILE_VERSION = 28, //!< incompatible file version
72+
E57_ERROR_BAD_FILE_LENGTH = 29, //!< size in file header not same as actual
73+
E57_ERROR_XML_PARSER_INIT = 30, //!< XML parser failed to initialize
74+
E57_ERROR_DUPLICATE_NAMESPACE_PREFIX = 31, //!< namespace prefix already defined
75+
E57_ERROR_DUPLICATE_NAMESPACE_URI = 32, //!< namespace URI already defined
76+
E57_ERROR_BAD_PROTOTYPE = 33, //!< bad prototype in CompressedVectorNode
77+
E57_ERROR_BAD_CODECS = 34, //!< bad codecs in CompressedVectorNode
78+
E57_ERROR_VALUE_OUT_OF_BOUNDS = 35, //!< element value out of min/max bounds
79+
E57_ERROR_CONVERSION_REQUIRED = 36, //!< conversion required to assign element value, but not requested
80+
E57_ERROR_BAD_PATH_NAME = 37, //!< E57 path name is not well formed
81+
E57_ERROR_NOT_IMPLEMENTED = 38, //!< functionality not implemented
82+
E57_ERROR_BAD_NODE_DOWNCAST = 39, //!< bad downcast from Node to specific node type
83+
E57_ERROR_WRITER_NOT_OPEN = 40, //!< CompressedVectorWriter is no longer open
84+
E57_ERROR_READER_NOT_OPEN = 41, //!< CompressedVectorReader is no longer open
85+
E57_ERROR_NODE_UNATTACHED = 42, //!< node is not yet attached to tree of ImageFile
86+
E57_ERROR_ALREADY_HAS_PARENT = 43, //!< node already has a parent
87+
E57_ERROR_DIFFERENT_DEST_IMAGEFILE = 44, //!< nodes were constructed with different destImageFiles
88+
E57_ERROR_IMAGEFILE_NOT_OPEN = 45, //!< destImageFile is no longer open
89+
E57_ERROR_BUFFERS_NOT_COMPATIBLE = 46, //!< SourceDestBuffers not compatible with previously given ones
90+
E57_ERROR_TOO_MANY_WRITERS = 47, //!< too many open CompressedVectorWriters of an ImageFile
91+
E57_ERROR_TOO_MANY_READERS = 48, //!< too many open CompressedVectorReaders of an ImageFile
92+
E57_ERROR_BAD_CONFIGURATION = 49, //!< bad configuration string
93+
E57_ERROR_INVARIANCE_VIOLATION = 50 //!< class invariance constraint violation in debug mode
94+
};
95+
96+
class E57Exception : public std::exception
97+
{
9498
public:
95-
void report(const char* reportingFileName=nullptr, int reportingLineNumber=0, const char* reportingFunctionName=nullptr, std::ostream& os = std::cout) const;
96-
ErrorCode errorCode() const;
99+
void report( const char *reportingFileName = nullptr, int reportingLineNumber = 0,
100+
const char *reportingFunctionName = nullptr, std::ostream &os = std::cout ) const;
101+
ErrorCode errorCode() const;
97102
std::string context() const;
98-
const char* what() const noexcept override;
103+
const char *what() const noexcept override;
99104

100105
// For debugging purposes:
101-
const char* sourceFileName() const;
102-
const char* sourceFunctionName() const;
103-
int sourceLineNumber() const;
106+
const char *sourceFileName() const;
107+
const char *sourceFunctionName() const;
108+
int sourceLineNumber() const;
104109

105-
//! \cond documentNonPublic The following isn't part of the API, and isn't documented.
110+
//! \cond documentNonPublic The following isn't part of the API, and isn't
111+
//! documented.
106112
E57Exception() = delete;
107-
E57Exception(ErrorCode ecode, const std::string &context,
108-
const std::string &srcFileName = nullptr, int srcLineNumber = 0,
109-
const char* srcFunctionName = nullptr);
113+
E57Exception( ErrorCode ecode, const std::string &context, const std::string &srcFileName = nullptr,
114+
int srcLineNumber = 0, const char *srcFunctionName = nullptr );
110115
~E57Exception() noexcept override = default;
111116

112117
protected:
113-
ErrorCode errorCode_;
118+
ErrorCode errorCode_;
114119
std::string context_;
115120
std::string sourceFileName_;
116-
const char* sourceFunctionName_;
117-
int sourceLineNumber_;
121+
const char *sourceFunctionName_;
122+
int sourceLineNumber_;
118123
//! \endcond
119-
};
120-
124+
};
121125

122-
namespace Utilities {
123-
// Get latest version of ASTM standard supported, and library id string
124-
void getVersions(int& astmMajor, int& astmMinor, std::string& libraryId);
126+
namespace Utilities
127+
{
128+
// Get latest version of ASTM standard supported, and library id string
129+
void getVersions( int &astmMajor, int &astmMinor, std::string &libraryId );
125130

126-
std::string errorCodeToString(ErrorCode ecode);
131+
std::string errorCodeToString( ErrorCode ecode );
132+
}
127133
}
128-
}
129-
130-
#endif

0 commit comments

Comments
 (0)