Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
StringView.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* StringView.cc (C) 2000-2021 */
9/* */
10/* Vue sur une chaîne de caractères UTF-8. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/base/StringView.h"
15
16#include <iostream>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Arccore
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
28writeBytes(std::ostream& o) const
29{
30 o.write((const char*)m_v.data(),m_v.size());
31}
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36std::ostream&
37operator<<(std::ostream& o,const StringView& str)
38{
39 str.writeBytes(o);
40 return o;
41}
42
43/*---------------------------------------------------------------------------*/
44/*---------------------------------------------------------------------------*/
45
46bool
47operator==(const StringView& a,const StringView& b)
48{
49 bool is_equal = (a.toStdStringView()==b.toStdStringView());
50 //std::cout << "COMPARE: a=" << a.length() << " '" << a << "'"
51 // << " b=" << b.length() << " '" << b << "' v=" << is_equal << '\n';
52 return is_equal;
53}
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58bool operator==(const char* a,const StringView& b)
59{
60 return operator==(StringView(a),b);
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66bool operator==(const StringView& a,const char* b)
67{
68 return operator==(a,StringView(b));
69}
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74bool operator<(const StringView& a,const StringView& b)
75{
76 return a.toStdStringView()<b.toStdStringView();
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82} // End namespace Arccore
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
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 sur une chaîne de caractères UTF-8.
Definition StringView.h:47
std::string_view toStdStringView() const ARCCORE_NOEXCEPT
Retourne une vue de la STL de la vue actuelle.
Definition StringView.h:112
void writeBytes(std::ostream &o) const
Écrit la chaîne au format UTF-8 sur le flot o.
Definition StringView.cc:28
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
bool operator<(const APReal &a, const APReal &b)
Emulation d'un réel en précision arbitraire.