Arcane  v3.15.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
StringVector.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/* StringVector.cc (C) 2000-2025 */
9/* */
10/* Liste de 'String'. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/collections/StringVector.h"
15
16#include "arccore/base/String.h"
17#include "arccore/collections/Array.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arccore
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
29{
30 public:
31
32 UniqueArray<String> m_values;
33};
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38StringVector::
39StringVector(const StringVector& rhs)
40{
41 if (rhs.m_p)
42 m_p = new Impl(*rhs.m_p);
43}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48StringVector::
49StringVector(StringVector&& rhs) noexcept
50: m_p(rhs.m_p)
51{
52 rhs.m_p = nullptr;
53}
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58StringVector& StringVector::
59operator=(const StringVector& rhs)
60{
61 if (&rhs != this) {
62 Impl* new_mp = nullptr;
63 if (rhs.m_p)
64 new_mp = new Impl(*rhs.m_p);
65 delete m_p;
66 m_p = new_mp;
67 }
68 return (*this);
69}
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74StringVector::
75~StringVector()
76{
77 delete m_p;
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83void StringVector::
84_checkNeedCreate()
85{
86 if (!m_p)
87 m_p = new Impl();
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93Int32 StringVector::
94size() const
95{
96 return (m_p ? m_p->m_values.size() : 0);
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102void StringVector::
103add(const String& str)
104{
105 _checkNeedCreate();
106 m_p->m_values.add(str);
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112String StringVector::
113operator[](Int32 index) const
114{
115 ARCCORE_CHECK_POINTER(m_p);
116 return m_p->m_values[index];
117}
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122} // namespace Arccore
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Integer size() const
Nombre d'éléments du vecteur.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Liste de 'String'.
Vecteur 1D de données avec sémantique par valeur (style STL).
Espace de nom de Arccore.
Definition ArcaneTypes.h:29