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

Method _setNextReal

plugins/e57/libE57Format/src/SourceDestBufferImpl.cpp:131–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131template <typename T> void SourceDestBufferImpl::_setNextReal( T inValue )
132{
133 static_assert( std::is_same<T, double>::value || std::is_same<T, float>::value,
134 "_setNextReal() requires float or double type" );
135
136 /// don't checkImageFileOpen
137
138 /// Verify have room
139 if ( nextIndex_ >= capacity_ )
140 {
141 throw E57_EXCEPTION2( ErrorInternal, "pathName=" + pathName_ );
142 }
143
144 /// Calc start of memory location, index into buffer using stride_ (the
145 /// distance between elements).
146 char *p = &base_[nextIndex_ * stride_];
147
148 switch ( memoryRepresentation_ )
149 {
150 case Int8:
151 if ( !doConversion_ )
152 {
153 throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
154 }
155 //??? fault if get special value: NaN, NegInf... (all other ints below
156 // too)
157 if ( inValue < INT8_MIN || INT8_MAX < inValue )
158 {
159 throw E57_EXCEPTION2( ErrorValueNotRepresentable,
160 "pathName=" + pathName_ + " value=" + toString( inValue ) );
161 }
162 *reinterpret_cast<int8_t *>( p ) = static_cast<int8_t>( inValue );
163 break;
164 case UInt8:
165 if ( !doConversion_ )
166 {
167 throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
168 }
169 if ( inValue < UINT8_MIN || UINT8_MAX < inValue )
170 {
171 throw E57_EXCEPTION2( ErrorValueNotRepresentable,
172 "pathName=" + pathName_ + " value=" + toString( inValue ) );
173 }
174 *reinterpret_cast<uint8_t *>( p ) = static_cast<uint8_t>( inValue );
175 break;
176 case Int16:
177 if ( !doConversion_ )
178 {
179 throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
180 }
181 if ( inValue < INT16_MIN || INT16_MAX < inValue )
182 {
183 throw E57_EXCEPTION2( ErrorValueNotRepresentable,
184 "pathName=" + pathName_ + " value=" + toString( inValue ) );
185 }
186 *reinterpret_cast<int16_t *>( p ) = static_cast<int16_t>( inValue );
187 break;
188 case UInt16:

Callers

nothing calls this directly

Calls 1

toStringFunction · 0.70

Tested by

no test coverage detected