14#include "arcane/std/internal/IosFile.h"
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/IOException.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/Real3.h"
34 return m_stream->eof();
41getNextLine(
const char* comment_char)
43 while (m_stream->good()) {
44 m_stream->getline(m_buf,
sizeof(m_buf) - 1);
47 if (m_buf[0] ==
'\n' || m_buf[0] ==
'\r')
49 bool is_comment =
true;
53 for (
int i = 0; is_comment && i < IOS_BFR_SZE && m_buf[i] !=
'\0'; ++i) {
54 if (!isspace(m_buf[i])) {
55 is_comment = (m_buf[i] == *comment_char);
62 for (
int i = 0; i < IOS_BFR_SZE && m_buf[i] !=
'\0'; ++i) {
64 if (m_buf[i] ==
'\n' || m_buf[i] ==
'\r') {
72 throw IOException(
"IosFile::getNexLine()",
"Unexpected EndOfFile");
81 return getNextLine(
nullptr);
93 while (m_stream->good()) {
94 int c = m_stream->peek();
97 if (std::isspace(c, std::locale::classic()))
117 (*m_stream) >> ws >> v;
118 if (m_stream->good())
120 throw IOException(
"IosFile::getReal()",
"Bad Real");
130 (*m_stream) >> ws >> v;
131 if (m_stream->good())
133 throw IOException(
"IosFile::getInteger()",
"Bad Integer");
143 (*m_stream) >> ws >> v;
144 if (m_stream->good())
146 throw IOException(
"IosFile::getInteger()",
"Bad Int64");
153lookForString(
const String& str)
155 const char* bfr = getNextLine();
157 std::istringstream iline(bfr);
161 return isEqualString(got, str);
168checkString(
const String& current_value,
const String& expected_value)
170 String current_value_low = current_value.lower();
171 String expected_value_low = expected_value.lower();
173 if (current_value_low != expected_value_low) {
174 String s =
"Expecting chain '" + expected_value +
"', found '" + current_value +
"'";
175 throw IOException(
"IosFile::checkString()", s);
183checkString(
const String& current_value,
const String& expected_value1,
const String& expected_value2)
185 String current_value_low = current_value.lower();
186 String expected_value1_low = expected_value1.lower();
187 String expected_value2_low = expected_value2.lower();
189 if (current_value_low != expected_value1_low && current_value_low != expected_value2_low) {
190 String s =
"Expecting chain '" + expected_value1 +
"' or '" + expected_value2 +
"', found '" + current_value +
"'";
191 throw IOException(
"IosFile::checkString()", s);
199isEqualString(
const String& current_value,
const String& expected_value)
201 String current_value_low = current_value.lower();
202 String expected_value_low = expected_value.lower();
203 return (current_value_low == expected_value_low);
212 m_stream->read(
reinterpret_cast<char*
>(bytes.data()), bytes.size());
213 if (!m_stream->good())
214 throw IOException(
"IosFile::readBytes()",
215 String::format(
"Can not read '{0}' bytes", bytes.size()));
Exception when an input/output error is detected.
void goToEndOfLine(void)
Reads all characters until a non-whitespace character.
View of an array of elements of type T.
Unicode character string.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
Impl::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of modifiable bytes.