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);
91 (*m_stream) >> ws >> v;
94 throw IOException(
"IosFile::getReal()",
"Bad Real");
104 (*m_stream) >> ws >> v;
105 if (m_stream->good())
107 throw IOException(
"IosFile::getInteger()",
"Bad Integer");
117 (*m_stream) >> ws >> v;
118 if (m_stream->good())
120 throw IOException(
"IosFile::getInteger()",
"Bad Int64");
127lookForString(
const String& str)
129 const char* bfr = getNextLine();
131 std::istringstream iline(bfr);
135 return isEqualString(got, str);
142checkString(
const String& current_value,
const String& expected_value)
144 String current_value_low = current_value.lower();
145 String expected_value_low = expected_value.lower();
147 if (current_value_low != expected_value_low) {
148 String s =
"Expecting chain '" + expected_value +
"', found '" + current_value +
"'";
149 throw IOException(
"IosFile::checkString()", s);
157checkString(
const String& current_value,
const String& expected_value1,
const String& expected_value2)
159 String current_value_low = current_value.lower();
160 String expected_value1_low = expected_value1.lower();
161 String expected_value2_low = expected_value2.lower();
163 if (current_value_low != expected_value1_low && current_value_low != expected_value2_low) {
164 String s =
"Expecting chain '" + expected_value1 +
"' or '" + expected_value2 +
"', found '" + current_value +
"'";
165 throw IOException(
"IosFile::checkString()", s);
173isEqualString(
const String& current_value,
const String& expected_value)
175 String current_value_low = current_value.lower();
176 String expected_value_low = expected_value.lower();
177 return (current_value_low == expected_value_low);
184readBytes(SmallSpan<std::byte> bytes)
186 m_stream->read(
reinterpret_cast<char*
>(bytes.data()),bytes.size());
187 if (!m_stream->good())
188 throw IOException(
"IosFile::readBytes()",
189 String::format(
"Can not read '{0}' bytes",bytes.size()));
196binaryRead(SmallSpan<Int32> values)
205binaryRead(SmallSpan<Int64> values)
214binaryRead(SmallSpan<double> values)
223binaryRead(SmallSpan<Real3> values)
232binaryRead(SmallSpan<Byte> values)
Lecteur des fichiers de maillage via la bibliothèque LIMA.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
detail::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets modifiables.