pass-thru object in assignment of primitive types (strings)

This commit is contained in:
Mark Olesen
2009-03-12 11:29:39 +01:00
parent e011328d99
commit eb3c47c75f
12 changed files with 93 additions and 74 deletions

View File

@ -196,36 +196,41 @@ Foam::word Foam::fileName::component
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::fileName::operator=(const fileName& str)
const Foam::fileName& Foam::fileName::operator=(const fileName& str)
{
string::operator=(str);
return *this;
}
void Foam::fileName::operator=(const word& str)
const Foam::fileName& Foam::fileName::operator=(const word& str)
{
string::operator=(str);
return *this;
}
void Foam::fileName::operator=(const string& str)
const Foam::fileName& Foam::fileName::operator=(const string& str)
{
string::operator=(str);
stripInvalid();
return *this;
}
void Foam::fileName::operator=(const std::string& str)
const Foam::fileName& Foam::fileName::operator=(const std::string& str)
{
string::operator=(str);
stripInvalid();
return *this;
}
void Foam::fileName::operator=(const char* str)
const Foam::fileName& Foam::fileName::operator=(const char* str)
{
string::operator=(str);
stripInvalid();
return *this;
}

View File

@ -158,11 +158,11 @@ public:
// Assignment
void operator=(const fileName&);
void operator=(const word&);
void operator=(const string&);
void operator=(const std::string&);
void operator=(const char*);
const fileName& operator=(const fileName&);
const fileName& operator=(const word&);
const fileName& operator=(const string&);
const fileName& operator=(const std::string&);
const fileName& operator=(const char*);
// IOstream operators

View File

@ -106,12 +106,12 @@ public:
// Assignment
inline void operator=(const keyType&);
inline void operator=(const word&);
inline const keyType& operator=(const keyType&);
inline const keyType& operator=(const word&);
//- Assign from regular expression.
inline void operator=(const string&);
inline void operator=(const char*);
inline const keyType& operator=(const string&);
inline const keyType& operator=(const char*);
// IOstream operators

View File

@ -89,34 +89,38 @@ inline bool Foam::keyType::isPattern() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::keyType::operator=(const keyType& s)
inline const Foam::keyType& Foam::keyType::operator=(const keyType& s)
{
// Bypass checking
string::operator=(s);
isPattern_ = s.isPattern_;
return *this;
}
inline void Foam::keyType::operator=(const word& s)
inline const Foam::keyType& Foam::keyType::operator=(const word& s)
{
word::operator=(s);
isPattern_ = false;
return *this;
}
inline void Foam::keyType::operator=(const string& s)
inline const Foam::keyType& Foam::keyType::operator=(const string& s)
{
// Bypass checking
string::operator=(s);
isPattern_ = true;
return *this;
}
inline void Foam::keyType::operator=(const char* s)
inline const Foam::keyType& Foam::keyType::operator=(const char* s)
{
// Bypass checking
string::operator=(s);
isPattern_ = false;
return *this;
}

View File

@ -117,10 +117,10 @@ public:
// Assignment
inline void operator=(const word&);
inline void operator=(const string&);
inline void operator=(const std::string&);
inline void operator=(const char*);
inline const word& operator=(const word&);
inline const word& operator=(const string&);
inline const word& operator=(const std::string&);
inline const word& operator=(const char*);
// Friend Operators

View File

@ -132,30 +132,34 @@ inline bool Foam::word::valid(char c)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::word::operator=(const word& q)
inline const Foam::word& Foam::word::operator=(const word& q)
{
string::operator=(q);
return *this;
}
inline void Foam::word::operator=(const string& q)
inline const Foam::word& Foam::word::operator=(const string& q)
{
string::operator=(q);
stripInvalid();
return *this;
}
inline void Foam::word::operator=(const std::string& q)
inline const Foam::word& Foam::word::operator=(const std::string& q)
{
string::operator=(q);
stripInvalid();
return *this;
}
inline void Foam::word::operator=(const char* q)
inline const Foam::word& Foam::word::operator=(const char* q)
{
string::operator=(q);
stripInvalid();
return *this;
}

View File

@ -187,22 +187,22 @@ public:
//- Assign copy
// Always case sensitive
inline void operator=(const wordRe&);
inline const wordRe& operator=(const wordRe&);
//- Copy word, never a regular expression
inline void operator=(const word&);
inline const wordRe& operator=(const word&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const string&);
inline const wordRe& operator=(const string&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const std::string&);
inline const wordRe& operator=(const std::string&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const char*);
inline const wordRe& operator=(const char*);
// IOstream operators

View File

@ -213,7 +213,7 @@ inline void Foam::wordRe::set(const char* str, const compOption opt)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::wordRe::operator=(const wordRe& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const wordRe& str)
{
string::operator=(str);
@ -225,34 +225,39 @@ inline void Foam::wordRe::operator=(const wordRe& str)
{
re_.clear();
}
return *this;
}
inline void Foam::wordRe::operator=(const word& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const word& str)
{
word::operator=(str);
re_.clear();
return *this;
}
inline void Foam::wordRe::operator=(const string& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const string& str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}
inline void Foam::wordRe::operator=(const std::string& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const std::string& str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}
inline void Foam::wordRe::operator=(const char* str)
inline const Foam::wordRe& Foam::wordRe::operator=(const char* str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}