MCPcopy Create free account
hub / github.com/PDAL/PDAL / construct2

Method construct2

plugins/e57/libE57Format/src/ImageFileImpl.cpp:86–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 void ImageFileImpl::construct2( const ustring &fileName, const ustring &mode )
87 {
88 // Second phase of construction, now we have a well-formed ImageFile object.
89
90#ifdef E57_VERBOSE
91 std::cout << "ImageFileImpl() called, fileName=" << fileName << " mode=" << mode << std::endl;
92#endif
93 unusedLogicalStart_ = sizeof( E57FileHeader );
94 fileName_ = fileName;
95
96 // Get shared_ptr to this object
97 ImageFileImplSharedPtr imf = shared_from_this();
98
99 // Accept "w" or "r" modes
100 isWriter_ = ( mode == "w" );
101
102 if ( !isWriter_ && ( mode != "r" ) )
103 {
104 throw E57_EXCEPTION2( ErrorBadAPIArgument, "mode=" + ustring( mode ) );
105 }
106
107 file_ = nullptr;
108
109 // Writing
110 if ( isWriter_ )
111 {
112 try
113 {
114 // Open file for writing, truncate if already exists.
115 file_ = new CheckedFile( fileName_, CheckedFile::Write, checksumPolicy );
116
117 std::shared_ptr<StructureNodeImpl> root( new StructureNodeImpl( imf ) );
118 root_ = root;
119 root_->setAttachedRecursive();
120
121 unusedLogicalStart_ = sizeof( E57FileHeader );
122 xmlLogicalOffset_ = 0;
123 xmlLogicalLength_ = 0;
124 }
125 catch ( ... )
126 {
127 delete file_;
128 file_ = nullptr;
129
130 throw;
131 }
132
133 return;
134 }
135
136 // Reading
137 try
138 {
139 // Open file for reading.
140 file_ = new CheckedFile( fileName_, CheckedFile::Read, checksumPolicy );
141
142 std::shared_ptr<StructureNodeImpl> root( new StructureNodeImpl( imf ) );
143 root_ = root;

Callers 1

ImageFileMethod · 0.80

Calls 4

physicalToLogicalMethod · 0.80
setAttachedRecursiveMethod · 0.45
initMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected