TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Nom.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16
17
18#ifndef Nom_included
19#define Nom_included
20
21#include <Objet_U.h>
22#include <cstring>
23#include <string>
24
25/*! @brief class Nom Une chaine de caractere pour nommer les objets de TRUST
26 *
27 * @sa Motcle
28 */
29
30class Nom : public Objet_U
31{
32 Declare_instanciable_sans_constructeur_ni_destructeur(Nom);
33public:
34 Nom(); // construit "??"
35 Nom(int i); // Nom(485)="485"
36 Nom(long i); // Nom(485)="485"
37 Nom(long long i); // Nom(485)="485"
38 Nom(const char* nom);
39 Nom(const std::string& nom);
40 Nom(const Nom&);
41 Nom(char c);
42 Nom(double );
43 Nom(double le_reel, const char* format);
44 ~Nom() override;
45
46 operator const char*() const;
47
48 Nom& majuscule();
49 int est_egal_a(const Objet_U&) const override;
50 int longueur() const ;
51 const Nom& le_nom() const override;
52
53 Nom& operator=(const char* const);
54 Nom& operator=(const Nom&);
55 Nom operator +(const Nom&) const;
56 Nom& operator +=(const Nom& x);
57 Nom& operator +=(const char *);
58 Nom& operator +=(char x);
59 Nom& operator +=(unsigned char x);
60 Nom& operator +=(int x);
61 Nom& suffix(const char* const) ;
62 const Nom getSuffix(const char* const) const ;
63 Nom& prefix(const char* const) ;
64 const Nom getPrefix(const char* const) const ;
65 Nom nom_me(int, const char* prefix=0, int without_padding=0) const;
66 Nom substr_old(const int, const int) const;
67 Nom basename() const;
68
69 virtual int find(const char* const n) const;
70 virtual int debute_par(const char* const n) const;
71 virtual int finit_par(const char* const n) const;
72
73 int find(const std::string& n) const;
74 int debute_par(const std::string&) const;
75 int finit_par(const std::string&) const;
76
77 friend int operator ==(const Nom& , const char* const) ;
78 friend int operator !=(const Nom& , const char* ) ;
79 friend int operator ==(const Nom& , const Nom&) ;
80 friend int operator !=(const Nom& , const Nom& ) ;
81 friend int operator ==(const char* const, const Nom&) ;
82 friend int operator !=(const char* const, const Nom&) ;
83 // so that Nom (and Motcle) can be used as a key in std::map :
84 friend bool operator <(const Nom&, const Nom&) ;
85
86 inline bool contient(const Nom& nom) const
87 {
88 std::size_t found = nom_.find(nom.nom_);
89 return found!=std::string::npos;
90 }
91 inline const char* getChar() const { return nom_.c_str(); }
92 inline const std::string& getString() const { return nom_; }
93 inline std::string& getString() { return nom_; }
94
95protected :
96
97 std::string nom_;
98};
99
100#endif // NOM_H
~Nom() override
Destructeur.
Definition Nom.cpp:173
const char * getChar() const
Definition Nom.h:91
Nom()
Constructeur par defaut.
Definition Nom.cpp:63
virtual int finit_par(const char *const n) const
Definition Nom.cpp:324
Nom substr_old(const int, const int) const
Retourne un nom selon la commande usuelle substr ATTENTION : deb = 1 => premier caractere de la chain...
Definition Nom.cpp:473
int est_egal_a(const Objet_U &) const override
Comparaison avec un Objet_U l'Objet_U est caste en Nom pour la comparaison.
Definition Nom.cpp:370
const Nom getPrefix(const char *const) const
Definition Nom.cpp:340
Nom & operator=(const char *const)
Copie la chaine nom.
Definition Nom.cpp:201
bool contient(const Nom &nom) const
Definition Nom.h:86
std::string nom_
Definition Nom.h:97
friend bool operator<(const Nom &, const Nom &)
Definition Nom.cpp:553
Nom nom_me(int, const char *prefix=0, int without_padding=0) const
Insere _prefix000n (n=me() ou nproc()) dans un nom de fichier (par ex:toto.
Definition Nom.cpp:387
const Nom getSuffix(const char *const) const
Definition Nom.cpp:281
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
virtual int find(const char *const n) const
Definition Nom.cpp:314
Nom & operator+=(const Nom &x)
Concatenation avec un Nom.
Definition Nom.cpp:223
int longueur() const
Renvoie le nombre de caracteres de la chaine du Nom y compris le caractere zero de fin de chaine.
Definition Nom.cpp:191
friend int operator==(const Nom &, const char *const)
Comparaison d'un nom avec une chaine de caractere Utilise strcmp.
Definition Nom.cpp:518
std::string & getString()
Definition Nom.h:93
Nom & prefix(const char *const)
Definition Nom.cpp:329
Nom & majuscule()
Transforme le nom en majuscules Seules les lettres 'a'-'z' sont modifiees.
Definition Nom.cpp:180
Nom operator+(const Nom &) const
Concatenation avec un Nom.
Definition Nom.cpp:358
Nom & suffix(const char *const)
Extraction de suffixe : Nom x("azerty");.
Definition Nom.cpp:271
Nom basename() const
Retourne fichier si le nom est sous la forme /toto/titi/fichier.
Definition Nom.cpp:486
const std::string & getString() const
Definition Nom.h:92
const Nom & le_nom() const override
Renvoie *this;.
Definition Nom.cpp:563
friend int operator!=(const Nom &, const char *)
Comparaison d'un nom avec une chaine de caractere.
Definition Nom.cpp:538
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55