Arcane  v3.14.10.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-2023 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-2023 */
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
18// On n'utilise pas directement ces fichiers mais on les inclus pour tester
19// la compilation. Lorsque les tests seront en place on pourra supprimer
20// ces inclusions
21#include "arccore/base/Array2View.h"
22#include "arccore/base/Array3View.h"
23#include "arccore/base/Array4View.h"
24#include "arccore/base/Span.h"
25#include "arccore/base/Span2.h"
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arccore
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36//! Lance une exception 'ArgumentException'
37ARCCORE_BASE_EXPORT void impl::
38arccoreThrowTooBigInteger [[noreturn]] (std::size_t size)
39{
40 ARCCORE_THROW(ArgumentException,"value '{0}' too big for Array size",size);
41}
42
43//! Lance une exception 'ArgumentException'
44ARCCORE_BASE_EXPORT void impl::
45arccoreThrowTooBigInt64 [[noreturn]] (std::size_t size)
46{
47 ARCCORE_THROW(ArgumentException,"value '{0}' too big to fit in Int64",size);
48}
49
50ARCCORE_BASE_EXPORT void impl::
51arccoreThrowNegativeSize [[noreturn]] (Int64 size)
52{
53 ARCCORE_THROW(ArgumentException,"invalid negative value '{0}' for Array size",size);
54}
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59void
60binaryWrite(std::ostream& ostr,const Span<const std::byte>& bytes)
61{
62 auto* ptr = reinterpret_cast<const char*>(bytes.data());
63 ostr.write(ptr,bytes.size());
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69void
70binaryRead(std::istream& istr,const Span<std::byte>& bytes)
71{
72 auto* ptr = reinterpret_cast<char*>(bytes.data());
73 istr.read(ptr,bytes.size());
74}
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79} // End namespace Arccore
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:209
constexpr __host__ __device__ pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:419
Vue d'un tableau d'éléments de type T.
Definition Span.h:510
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
void binaryRead(std::istream &istr, const Span< std::byte > &bytes)
Lit en binaire le contenu de bytes depuis le flot istr.
Definition ArrayView.cc:70
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:60