51 std::streampos tag_start_pos = input.tellg();
58 input.seekg(tag_start_pos);
95 int& out_value,
bool& out_blank)
104 out_value = (int)strtol(cstr, &endp, 10);
115 output << std::setw(
field_width) << std::right << std::setfill(
'0');
117 output << std::showpos;
119 output << std::noshowpos;
122 return !output.fail();
154 out_value = _strtoi64(cstr, &endp, 10);
157 out_value = ::strtoll(cstr, &endp, 10);
161 #else //VXL_HAS_INT_64 162 out_value = strtol(cstr, &endp, 10);
164 #endif //VXL_HAS_INT_64 175 output << std::setw(
field_width) << std::right << std::setfill(
'0');
177 output << std::showpos;
179 output << std::noshowpos;
182 return !output.fail();
191 precision(precision),
201 double& out_value,
bool& out_blank)
210 out_value = strtod(cstr, &endp);
226 output << std::showpos;
228 output << std::noshowpos;
230 output << std::internal << std::setfill(
'0') << std::setprecision(
precision)
232 return !output.fail();
241 mantissa_width + exponent_width + 5),
242 mantissa_width(mantissa_width),
243 exponent_width(exponent_width)
252 double& out_value,
bool& out_blank)
261 out_value = strtod(cstr, &endp);
263 const char base_sign = cstr[0];
264 const bool base_sign_ok = base_sign==
'+' || base_sign==
'-';
265 const bool decimal_ok = cstr[2]==
'.';
268 const bool exp_sign_ok = exp_sign==
'+' || exp_sign==
'-';
284 std::ostringstream buffer;
285 buffer << std::setw(
field_width) << std::scientific
286 << std::showpos << std::uppercase
287 << std::internal << std::setfill(
'0') << std::setprecision(
mantissa_width)
289 std::string buffer_string = buffer.str();
290 auto length = (
unsigned int)(buffer_string.length());
292 output << buffer_string.substr(0,length-3);
296 return !output.fail();
338 input.get(out_value);
340 out_blank = (out_value ==
' ');
341 return !input.fail();
348 return !output.fail();
366 std::string& out_value,
374 std::string str = std::string(cstr);
376 std::string::size_type end_pos = str.find_last_not_of(
' ')+1;
377 if (end_pos == std::string::npos) {
380 out_value = str.substr(0, end_pos);
387 output << std::setw(
field_width) << std::left << std::setfill(
' ') << value;
388 return !output.fail();
417 std::string token = entry.first;
418 #if 0 // disable the err message 440 if (!insert(std::make_pair(token, pretty_name)).second) {
441 std::cerr <<
"vil_nitf2_enum_values: WARNING: Ignoring definition " 442 << token <<
"; token already defined for this enumeration.\n";
454 vil_nitf2::type_tagged_record_sequence, 1 )
470 bool error_reading_tre =
false;
472 while (input.
tell() < end && !error_reading_tre) {
475 out_value.push_back(record);
477 error_reading_tre &= !record;
479 if (input.
tell() != end) {
480 VIL_NITF2_LOG(log_info) <<
"\nSeeking to end of TRE sequence field.\n";
482 if (input.
tell() != end) {
483 std::cerr <<
"\nSeek to end of TRE sequence field failed.\n";
484 error_reading_tre =
true;
488 return !error_reading_tre;
vxl_int_32 vil_nitf2_long
virtual vil_streampos tell() const =0
Return file pointer.
virtual vil_streampos write(void const *buf, vil_streampos n)=0
Write n bytes from buf. Returns number of bytes written.
bool write(std::ostream &output, int field_width) const
bool read(std::istream &input, int field_width, bool &out_blank)
virtual void seek(vil_streampos position)=0
Goto file pointer.
#define VIL_NITF2_LOG(LEVEL)
virtual vil_streampos read(void *buf, vil_streampos n)=0
Read n bytes into buf. Returns number of bytes read.
Stream interface for VIL image loaders.
virtual bool write(std::ostream &output, int field_width)=0
virtual bool read(std::istream &input, int field_width, bool &out_blank)=0
static vil_nitf2_tagged_record * create(vil_nitf2_istream &input)
vil_nitf2_enum_values & value(std::string token, std::string pretty_name="")