12#ifndef ARCCORE_BASE_STRINGVIEW_H
13#define ARCCORE_BASE_STRINGVIEW_H
18#include "arccore/base/Span.h"
54 :
StringView(str ? std::string_view(str) : std::string_view()){}
57 : m_v(
reinterpret_cast<const Byte*
>(str.data()),str.size()){}
68 operator=(str ? std::string_view(str) : std::string_view());
99 constexpr Int64 length() const ARCCORE_NOEXCEPT {
return m_v.size(); }
102 constexpr Int64 size() const ARCCORE_NOEXCEPT {
return m_v.size(); }
105 constexpr bool empty() const ARCCORE_NOEXCEPT {
return size()==0; }
114 return std::string_view(
reinterpret_cast<const char*
>(m_v.data()),m_v.size());
144 friend ARCCORE_BASE_EXPORT
bool operator==(
const char* a,
const StringView& b);
160 friend ARCCORE_BASE_EXPORT
bool operator==(
const StringView& a,
const char* b);
184 void writeBytes(std::ostream& o)
const;
Déclarations des types de la composante 'base' de Arccore.
Vue d'un tableau d'éléments de type T.
Vue sur une chaîne de caractères UTF-8.
constexpr StringView & operator=(const StringView &str)=default
Copie la vue str dans cette instance.
constexpr StringView(Span< const Byte > str) ARCCORE_NOEXCEPT
Créé une chaîne à partir de str dans l'encodage UTF-8.
constexpr Int64 size() const ARCCORE_NOEXCEPT
Longueur en octet de la chaîne de caractères.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Retourne la conversion de l'instance dans l'encodage UTF-8.
friend bool operator!=(const char *a, const StringView &b)
Compare deux chaînes unicode.
std::string_view toStdStringView() const ARCCORE_NOEXCEPT
Retourne une vue de la STL de la vue actuelle.
~StringView()=default
Libère les ressources.
StringView(std::string_view str) ARCCORE_NOEXCEPT
Créé une chaîne à partir de str dans l'encodage UTF-8.
constexpr Int64 length() const ARCCORE_NOEXCEPT
Longueur en octet de la chaîne de caractères.
StringView & operator=(std::string_view str) ARCCORE_NOEXCEPT
Créé une vue à partir de str codé en UTF-8.
friend bool operator!=(const StringView &a, const StringView &b)
Compare deux chaînes unicode.
constexpr StringView & operator=(Span< const Byte > str) ARCCORE_NOEXCEPT
Créé une vue à partir de str codé en UTF-8.
friend ARCCORE_BASE_EXPORT bool operator==(const StringView &a, const StringView &b)
Compare deux vues.
StringView(const char *str) ARCCORE_NOEXCEPT
Créé une vue à partir de str codé en UTF-8. str peut être nul.
constexpr bool empty() const ARCCORE_NOEXCEPT
Vrai si la chaîne est nulle ou vide.
friend bool operator!=(const StringView &a, const char *b)
Compare deux chaînes unicode.
StringView & operator=(const char *str) ARCCORE_NOEXCEPT
Créé une vue à partir de str codé en UTF-8.
StringView()=default
Crée une vue sur une chaîne vide.
constexpr StringView(const StringView &str)=default
Opérateur de recopie.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
bool operator<(const Item &item1, const Item &item2)
Compare deux entités.
unsigned char Byte
Type d'un octet.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.