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);
92 while (m_stream->good()) {
93 char c = m_stream->peek();
108 (*m_stream) >> ws >> v;
109 if (m_stream->good())
111 throw IOException(
"IosFile::getReal()",
"Bad Real");
121 (*m_stream) >> ws >> v;
122 if (m_stream->good())
124 throw IOException(
"IosFile::getInteger()",
"Bad Integer");
134 (*m_stream) >> ws >> v;
135 if (m_stream->good())
137 throw IOException(
"IosFile::getInteger()",
"Bad Int64");
144lookForString(
const String& str)
146 const char* bfr = getNextLine();
147 std::cout <<
"[IosFile::getString] Looking for '" << str <<
"' len=" << str.length() <<
"\n";
148 std::istringstream iline(bfr);
151 std::cout <<
"[IosFile::getString] got='" << got <<
"' len=" << got.length() <<
"\n";
152 return isEqualString(got, str);
159checkString(
const String& current_value,
const String& expected_value)
161 String current_value_low = current_value.lower();
162 String expected_value_low = expected_value.lower();
164 if (current_value_low != expected_value_low) {
165 String s =
"Expecting chain '" + expected_value +
"', found '" + current_value +
"'";
166 throw IOException(
"IosFile::checkString()", s);
174checkString(
const String& current_value,
const String& expected_value1,
const String& expected_value2)
176 String current_value_low = current_value.lower();
177 String expected_value1_low = expected_value1.lower();
178 String expected_value2_low = expected_value2.lower();
180 if (current_value_low != expected_value1_low && current_value_low != expected_value2_low) {
181 String s =
"Expecting chain '" + expected_value1 +
"' or '" + expected_value2 +
"', found '" + current_value +
"'";
182 throw IOException(
"IosFile::checkString()", s);
190isEqualString(
const String& current_value,
const String& expected_value)
192 String current_value_low = current_value.lower();
193 String expected_value_low = expected_value.lower();
194 return (current_value_low == expected_value_low);
203 m_stream->read(
reinterpret_cast<char*
>(bytes.data()),bytes.size());
204 if (!m_stream->good())
205 throw IOException(
"IosFile::readBytes()",
206 String::format(
"Can not read '{0}' bytes",bytes.size()));
Exception lorsqu'une erreur d'entrée/sortie est détectée.
void goToEndOfLine(void)
Lit tous les caractères jusqu'à un caractère non blanc.
Vue d'un tableau d'éléments de type T.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
impl::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets modifiables.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
double Real
Type représentant un réel.