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
14#include "arccore/base/ArrayView.h"
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
22#include "arccore/base/Array2View.h"
23#include "arccore/base/Array3View.h"
24#include "arccore/base/Array4View.h"
25#include "arccore/base/Span.h"
26#include "arccore/base/Span2.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37//! Lance une exception 'ArgumentException'
38ARCCORE_BASE_EXPORT void impl::
39arccoreThrowTooBigInteger [[noreturn]] (std::size_t size)
40{
41 ARCCORE_THROW(ArgumentException,"value '{0}' too big for Array size",size);
42}
43
44//! Lance une exception 'ArgumentException'
45ARCCORE_BASE_EXPORT void impl::
46arccoreThrowTooBigInt64 [[noreturn]] (std::size_t size)
47{
48 ARCCORE_THROW(ArgumentException,"value '{0}' too big to fit in Int64",size);
49}
50
51ARCCORE_BASE_EXPORT void impl::
52arccoreThrowNegativeSize [[noreturn]] (Int64 size)
53{
54 ARCCORE_THROW(ArgumentException,"invalid negative value '{0}' for Array size",size);
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60void
61binaryWrite(std::ostream& ostr,const Span<const std::byte>& bytes)
62{
63 auto* ptr = reinterpret_cast<const char*>(bytes.data());
64 ostr.write(ptr,bytes.size());
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
70void
71binaryRead(std::istream& istr,const Span<std::byte>& bytes)
72{
73 auto* ptr = reinterpret_cast<char*>(bytes.data());
74 istr.read(ptr,bytes.size());
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80void Impl::ExtentStorageBase::
81_throwBadSize(Int64 wanted_size, Int64 expected_size)
82{
83 ARCCORE_FATAL("Bad size value for fixed extent size={0} expected={1}", wanted_size, expected_size);
84}
85
86/*---------------------------------------------------------------------------*/
87/*---------------------------------------------------------------------------*/
88
89} // End namespace Arccore
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
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:71
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:61