Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ArrayView.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ArrayView.cc (C) 2000-2025 */
9/* */
10/* Déclarations générales de Arccore. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
15#include "arccore/base/ArgumentException.h"
16#include "arccore/base/TraceInfo.h"
17#include "arccore/base/FatalErrorException.h"
18
19// On n'utilise pas directement ces fichiers mais on les inclus pour tester
20// la compilation. Lorsque les tests seront en place on pourra supprimer
21// ces inclusions
25#include "arccore/base/Span.h"
26#include "arccore/base/Span2.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*!
31 * \file Span.h
32 * \brief Types et fonctions associés aux classes SpanImpl, SmallSpan and Span.
33 */
34/*!
35 * \file Span2.h
36 * \brief Types et fonctions associés aux classes Span2Impl, Small2Span and Span2.
37 */
38/*!
39 * \file ArrayView.h
40 * \brief Types et fonctions associés aux classes ArrayView et ConstArrayView.
41 */
42/*!
43 * \file Array2View.h
44 * \brief Types et fonctions associés aux classes Array2View et ConstArray2View.
45 */
46/*!
47 * \file Array3View.h
48 * \brief Types et fonctions associés aux classes Array3View et ConstArray3View.
49 */
50/*!
51 * \file Array4View.h
52 * \brief Types et fonctions associés aux classes Array4View et ConstArray4View.
53 */
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57namespace Arcane
58{
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
63//! Lance une exception 'ArgumentException'
64ARCCORE_BASE_EXPORT void impl::
65arccoreThrowTooBigInteger [[noreturn]] (std::size_t size)
66{
67 ARCCORE_THROW(ArgumentException,"value '{0}' too big for Array size",size);
68}
69
70//! Lance une exception 'ArgumentException'
71ARCCORE_BASE_EXPORT void impl::
72arccoreThrowTooBigInt64 [[noreturn]] (std::size_t size)
73{
74 ARCCORE_THROW(ArgumentException,"value '{0}' too big to fit in Int64",size);
75}
76
77ARCCORE_BASE_EXPORT void impl::
78arccoreThrowNegativeSize [[noreturn]] (Int64 size)
79{
80 ARCCORE_THROW(ArgumentException,"invalid negative value '{0}' for Array size",size);
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86void
87binaryWrite(std::ostream& ostr,const Span<const std::byte>& bytes)
88{
89 auto* ptr = reinterpret_cast<const char*>(bytes.data());
90 ostr.write(ptr,bytes.size());
91}
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96void
97binaryRead(std::istream& istr,const Span<std::byte>& bytes)
98{
99 auto* ptr = reinterpret_cast<char*>(bytes.data());
100 istr.read(ptr,bytes.size());
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106void Impl::ExtentStorageBase::
107_throwBadSize(Int64 wanted_size, Int64 expected_size)
108{
109 ARCCORE_FATAL("Bad size value for fixed extent size={0} expected={1}", wanted_size, expected_size);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115} // End namespace Arccore
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
#define ARCCORE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ARCCORE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
Types et fonctions associés aux classes Span2Impl, Small2Span and Span2.
Types et fonctions associés aux classes SpanImpl, SmallSpan and Span.
Types et fonctions associés aux classes Array2View et ConstArray2View.
Types et fonctions associés aux classes Array3View et ConstArray3View.
Types et fonctions associés aux classes Array4View et ConstArray4View.
Types et fonctions associés aux classes ArrayView et ConstArrayView.
Exception lorsqu'un argument est invalide.
constexpr __host__ __device__ pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:537
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:325
Vue d'un tableau d'éléments de type T.
Definition Span.h:633
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
void binaryRead(std::istream &istr, const Span< std::byte > &bytes)
Lit en binaire le contenu de bytes depuis le flot istr.
Definition ArrayView.cc:97
void binaryWrite(std::ostream &ostr, const Span< const std::byte > &bytes)
Ecrit en binaire le contenu de bytes sur le flot ostr.
Definition ArrayView.cc:87