TrioCFD 1.9.9_beta
TrioCFD documentation
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: a character string for naming TRUST objects.
26 *
27 * @sa Motcle
28 */
29
30class Nom : public Objet_U
31{
32 Declare_instanciable_sans_constructeur_ni_destructeur(Nom);
33public:
34 Nom(); // constructs "??"
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
Destructor.
Definition Nom.cpp:169
const char * getChar() const
Definition Nom.h:91
Nom()
Default constructor. Creates the string "??".
Definition Nom.cpp:59
virtual int finit_par(const char *const n) const
Definition Nom.cpp:319
Nom substr_old(const int, const int) const
Returns a name using the usual substr command. NOTE: deb = 1 means the first character of the string.
Definition Nom.cpp:466
int est_egal_a(const Objet_U &) const override
Comparison with an Objet_U. The Objet_U is cast to Nom for the comparison.
Definition Nom.cpp:365
const Nom getPrefix(const char *const) const
Definition Nom.cpp:335
Nom & operator=(const char *const)
Copies the string nom.
Definition Nom.cpp:197
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:545
Nom nom_me(int, const char *prefix=0, int without_padding=0) const
Inserts _prefix000n (n=me() or nproc()) into a file name (e.g. toto.titi) to produce toto_prefix000n....
Definition Nom.cpp:380
const Nom getSuffix(const char *const) const
Definition Nom.cpp:276
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
virtual int find(const char *const n) const
Definition Nom.cpp:309
Nom & operator+=(const Nom &x)
Concatenation with a Nom.
Definition Nom.cpp:219
int longueur() const
Returns the number of characters in the Nom string, including the null terminator.
Definition Nom.cpp:187
friend int operator==(const Nom &, const char *const)
Compares a name with a character string using strcmp.
Definition Nom.cpp:510
std::string & getString()
Definition Nom.h:93
Nom & prefix(const char *const)
Definition Nom.cpp:324
Nom & majuscule()
Converts the name to uppercase. Only letters 'a'-'z' are modified.
Definition Nom.cpp:176
Nom operator+(const Nom &) const
Concatenation with a Nom.
Definition Nom.cpp:353
Nom & suffix(const char *const)
Suffix extraction: Nom x("azerty");.
Definition Nom.cpp:266
Nom basename() const
Returns the filename part if the name is in the form /toto/titi/filename.
Definition Nom.cpp:478
const std::string & getString() const
Definition Nom.h:92
const Nom & le_nom() const override
Returns *this.
Definition Nom.cpp:555
friend int operator!=(const Nom &, const char *)
Compares a name with a character string.
Definition Nom.cpp:530
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54