PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
PString.h
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #ifndef __PSTRING_H__
8 #define __PSTRING_H__
9 
10 #include <string.h>
11 #include <string>
12 #include <iostream>
13 
14 #include "convertToString.h"
15 
17 class PString : public std::string{
18  public:
19  PString();
20  PString(const std::string & str);
21  PString(const PString & other);
22  virtual ~PString();
23  PString & operator = (const PString & other);
24 
26 
29  template<typename T>
30  PString & operator = (const T & other){
31  std::string tmp(convertToString(other));
32  copyPString(tmp);
33  return *this;
34  }
35 
36  PString & operator += (const PString & other);
37  PString & operator += (const std::string & other);
38 
40 
43  template<typename T>
44  PString & operator += (const T & other){
45  std::string tmp(convertToString(other));
46  concatenatePString(tmp);
47  return *this;
48  }
49 
51 
54  template<typename T>
55  PString & operator << (const T & other){
56  std::string tmp(convertToString(other));
57  concatenatePString(tmp);
58  return *this;
59  }
60 
61  friend PString operator + (const PString & other1, const PString & other2);
62  friend PString operator << (const PString & other1, const PString & other2);
63 
65 
69  template<typename T>
70  friend PString operator + (const PString & other1, const T & other2){
71  PString res(other1);
72  res += other2;
73  return res;
74  }
75 
77 
81  template<typename T>
82  friend PString operator + (const T & other1, const PString & other2){
83  PString res;
84  res += other1;
85  res += other2;
86  return res;
87  }
88 
89  protected:
90  void copyPString(const PString & other);
91  void copyPString(const std::string & other);
92 
93  void concatenatePString(const PString & other);
94  void concatenatePString(const std::string & other);
95  private:
96  void initialisationPString();
97 };
98 
99 #endif
100 
convertToString
std::string convertToString(const T &val)
Convert a type into a string.
Definition: convertToString_impl.h:17
PString::concatenatePString
void concatenatePString(const PString &other)
Concatenate a PString into the current PString.
Definition: PString.cpp:108
PString::operator<<
PString & operator<<(const T &other)
Append type in PString.
Definition: PString.h:59
PString::operator+
friend PString operator+(const PString &other1, const PString &other2)
Concatenate 2 PString together.
Definition: PString.cpp:72
PString::PString
PString()
Default constructeur of PString.
Definition: PString.cpp:11
convertToString.h
createReleaseCurl.str
str
Definition: createReleaseCurl.py:128
PString::initialisationPString
void initialisationPString()
Initialisation function of the class PString.
Definition: PString.cpp:126
PString
Extends the std::string.
Definition: PString.h:17
PString::copyPString
void copyPString(const PString &other)
Copy function of PString.
Definition: PString.cpp:92
PString::operator=
PString & operator=(const PString &other)
Definition of equal operator of PString.
Definition: PString.cpp:44
PString::~PString
virtual ~PString()
Destructeur of PString.
Definition: PString.cpp:36
PString::operator+=
PString & operator+=(const PString &other)
Add a PString to an other.
Definition: PString.cpp:53