Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IIOMng.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* IIOMng.h (C) 2000-2025 */
9/* */
10/* Interface of the input-output manager. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IIOMNG_H
13#define ARCANE_CORE_IIOMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \ingroup IO
31 * \brief Interface of the input/output manager.
32 *
33 * \todo input/output manager allowing encapsulation
34 * of file management in parallel.
35 */
36class ARCANE_CORE_EXPORT IIOMng
37{
38 public:
39
40 virtual ~IIOMng() = default; //!< Frees resources
41
42 public:
43
44 /*!
45 * \brief Reads and parses the XML file \a filename.
46 *
47 * In case of an error, returns 0.
48 * The caller owns the returned instance and must
49 * destroy it using the delete operator.
50 * If a schema name is specified, the consistency
51 * of the file relative to the schema is checked.
52 */
53 virtual IXmlDocumentHolder*
54 parseXmlFile(const String& filename, const String& schemaname = String{}) = 0;
55
56 /*!
57 * \brief Reads and parses the XML file \a filename.
58 *
59 * In case of an error, returns 0.
60 * The caller owns the returned instance and must
61 * destroy it using the delete operator.
62 * The consistency of the file relative to the schema is checked;
63 * The schema name is provided only for error message processing.
64 */
65 virtual IXmlDocumentHolder* parseXmlFile(const String& filename,
66 const String& schemaname,
67 ConstArrayView<Byte> schema_data) = 0;
68
69 /*!
70 * \brief Reads and parses the XML file contained in the buffer \a buffer.
71 *
72 * In case of an error, returns 0.
73 * The caller owns the returned instance and must
74 * destroy it using the delete operator.
75 * The argument \a name associates a name with the memory area that is
76 * used for displaying error messages.
77 */
78 virtual IXmlDocumentHolder* parseXmlBuffer(Span<const Byte> buffer, const String& name) = 0;
79
80 /*!
81 * \brief Reads and parses the XML file contained in the buffer \a buffer.
82 *
83 * In case of an error, returns 0.
84 * The caller owns the returned instance and must
85 * destroy it using the delete operator.
86 * The argument \a name associates a name with the memory area that is
87 * used for displaying error messages.
88 */
90
91 /*!
92 * \brief Reads and parses the XML file contained in the string \a str.
93 *
94 * In case of an error, returns 0.
95 * The caller owns the returned instance and must
96 * destroy it using the delete operator.
97 * The argument \a name associates a name with the memory area that is
98 * used for displaying error messages.
99 */
100 virtual IXmlDocumentHolder* parseXmlString(const String& str, const String& name) = 0;
101
102 /*! \brief Writes the XML tree of the document \a doc to the file filename.
103 * \retval true in case of an error,
104 * \return false in case of success.
105 */
106 virtual bool writeXmlFile(IXmlDocumentHolder* doc, const String& filename, const bool indented = false) = 0;
107
108 /*!
109 * \brief Collective reading of a file.
110 *
111 * Collectively reads the file \a filename and returns its
112 * content in \a bytes. The file is considered a binary file.
113 * Collective reading means that all
114 * processors call this operation and will read the same file.
115 * The implementation can then optimize disk access by grouping the
116 * actual reading on one or more processors and then sending the
117 * file content to the others.
118 *
119 * \retval true in case of an error
120 * \retval false if everything is okay.
121 */
122 virtual bool collectiveRead(const String& filename, ByteArray& bytes) = 0;
123
124 /*!
125 * \brief Collective reading of a file.
126 *
127 * Collectively reads the file \a filename and returns its
128 * content in \a bytes. The file is considered a binary file
129 * if \a is_binary is true.
130 * Collective reading means that all
131 * processors call this operation and will read the same file.
132 * The implementation can then optimize disk access by grouping the
133 * actual reading on one or more processors and then sending the
134 * file content to the others.
135 *
136 * \retval true in case of an error
137 * \retval false if everything is okay.
138 */
139 virtual bool collectiveRead(const String& filename, ByteArray& bytes, bool is_binary) = 0;
140
141 /*!
142 * \brief Local reading of a file.
143 *
144 * Locally reads the file \a filename and returns its
145 * content in \a bytes. The file is considered a binary file.
146 * This operation is not collective.
147 *
148 * \retval true in case of an error.
149 * \retval false if everything is okay.
150 *
151 * \warning also returns true if the file is empty.
152 * \warning if the ByteUniqueArray must be converted to a String, a terminal 0 must be added beforehand (bytes.add(0))
153 */
154 virtual bool localRead(const String& filename, ByteArray& bytes) = 0;
155
156 /*!
157 * \brief Local reading of a file.
158 *
159 * Locally reads the file \a filename and returns its
160 * content in \a bytes.
161 * This operation is not collective.
162 *
163 * \retval true in case of an error.
164 * \retval false if everything is okay.
165 *
166 * \warning also returns true if the file is empty.
167 * \warning if the ByteUniqueArray must be converted to a String, a terminal 0 must be added beforehand (bytes.add(0))
168 */
169 virtual bool localRead(const String& filename, ByteArray& bytes, bool is_binary) = 0;
170};
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175} // namespace Arcane
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180#endif
Declarations of Arcane's general types.
Constant view of an array of type T.
Interface of the input/output manager.
Definition IIOMng.h:37
virtual ~IIOMng()=default
Frees resources.
virtual bool writeXmlFile(IXmlDocumentHolder *doc, const String &filename, const bool indented=false)=0
Writes the XML tree of the document doc to the file filename.
virtual bool localRead(const String &filename, ByteArray &bytes, bool is_binary)=0
Local reading of a file.
virtual IXmlDocumentHolder * parseXmlFile(const String &filename, const String &schemaname, ConstArrayView< Byte > schema_data)=0
Reads and parses the XML file filename.
virtual IXmlDocumentHolder * parseXmlBuffer(Span< const std::byte > buffer, const String &name)=0
Reads and parses the XML file contained in the buffer buffer.
virtual bool localRead(const String &filename, ByteArray &bytes)=0
Local reading of a file.
virtual IXmlDocumentHolder * parseXmlFile(const String &filename, const String &schemaname=String{})=0
Reads and parses the XML file filename.
virtual bool collectiveRead(const String &filename, ByteArray &bytes, bool is_binary)=0
Collective reading of a file.
virtual bool collectiveRead(const String &filename, ByteArray &bytes)=0
Collective reading of a file.
virtual IXmlDocumentHolder * parseXmlString(const String &str, const String &name)=0
Reads and parses the XML file contained in the string str.
virtual IXmlDocumentHolder * parseXmlBuffer(Span< const Byte > buffer, const String &name)=0
Reads and parses the XML file contained in the buffer buffer.
Manager of a DOM document.
View of an array of elements of type T.
Definition Span.h:635
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121