gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
Gambit::Fstring< len > Class Template Reference

Farray specialization for Fortran strings. More...

#include <util_types.hpp>

Inheritance diagram for Gambit::Fstring< len >:
Collaboration diagram for Gambit::Fstring< len >:

Public Member Functions

 Fstring ()
 
 Fstring (const std::string &in)
 
 Fstring (const char *in)
 
 Fstring (char in)
 
template<int ilen>
 Fstring (const Fstring< ilen > &in)
 
Fstringoperator= (const std::string &in)
 
Fstringoperator= (const char *in)
 
Fstringoperator= (char in)
 
template<int ilen>
Fstringoperator= (const Fstring< ilen > &in)
 
std::string str () const
 Get std::string copy of the Fstring, including all trailing spaces. More...
 
std::string trimmed_str () const
 Get std::string copy of the Fstring without trailing spaces. More...
 
bool operator== (std::string str)
 
- Public Member Functions inherited from Gambit::Farray< char, 1, len >
 Farray ()
 
 Farray (Farray< char, lims... > &in)
 
 Farray (const char val)
 
enable_if_all_member< allowed_types, char &, Args... >::type::type operator() (Args ... a)
 
enable_if_all_member< allowed_types, const char &, Args... >::type::type operator() (Args ... a) const
 
Farray< char, lims... > & operator= (const Farray< char, lims... > &orig)
 
Farray< char, lims... > & operator= (const char val)
 

Additional Inherited Members

- Public Types inherited from Gambit::Farray< char, 1, len >
typedef calc_nElem< lims... > nElem
 
- Public Attributes inherited from Gambit::Farray< char, 1, len >
char array [nElem::val]
 
- Protected Types inherited from Gambit::Farray< char, 1, len >
typedef mult_types< short, const short, short &, const short &, unsigned short, const unsigned short, unsigned short &, const unsigned short &, int, const int, int &, const int &, unsigned, const unsigned, unsigned &, const unsigned &, long, const long, long &, const long &, unsigned long, const unsigned long, unsigned long &, const unsigned long &, long long, const long long, long long &, const long long &, unsigned long long, const unsigned long long, unsigned long long &, const unsigned long long &> allowed_types
 

Detailed Description

template<int len>
class Gambit::Fstring< len >

Farray specialization for Fortran strings.

This is a 1-dimensional char array with indices 1 to len. It has assignment operators for standard string types, and accessors that return std::string objects. Strings longer than len will be truncated by the assignment operators, and shorter strings will be given trailing spaces. Syntax: Fstring<[string length]> DO NOT UNDER ANY CIRCUMSTANCE add new member variables to this class!

Definition at line 418 of file util_types.hpp.

Constructor & Destructor Documentation

◆ Fstring() [1/5]

template<int len>
Gambit::Fstring< len >::Fstring ( )
inline

Definition at line 421 of file util_types.hpp.

421 {}

◆ Fstring() [2/5]

template<int len>
Gambit::Fstring< len >::Fstring ( const std::string &  in)
inline

Definition at line 422 of file util_types.hpp.

422 {*this = in;}

◆ Fstring() [3/5]

template<int len>
Gambit::Fstring< len >::Fstring ( const char *  in)
inline

Definition at line 423 of file util_types.hpp.

423 {*this = in;}

◆ Fstring() [4/5]

template<int len>
Gambit::Fstring< len >::Fstring ( char  in)
inline

Definition at line 424 of file util_types.hpp.

424 {*this = in;}

◆ Fstring() [5/5]

template<int len>
template<int ilen>
Gambit::Fstring< len >::Fstring ( const Fstring< ilen > &  in)
inline

Definition at line 426 of file util_types.hpp.

426 {*this = in;}

Member Function Documentation

◆ operator=() [1/4]

template<int len>
Fstring& Gambit::Fstring< len >::operator= ( const std::string &  in)
inline

Definition at line 427 of file util_types.hpp.

428  {
429  for(unsigned int i=0; i<len; i++)
430  {
431  Farray<char,1,len>::array[i] = (i<in.length()) ? in[i] : ' ';
432  }
433  return *this;
434  }

◆ operator=() [2/4]

template<int len>
Fstring& Gambit::Fstring< len >::operator= ( const char *  in)
inline

Definition at line 435 of file util_types.hpp.

436  {
437  for(unsigned int i=0; i<len; i++)
438  {
439  Farray<char,1,len>::array[i] = (i<std::strlen(in)) ? in[i] : ' ';
440  }
441  return *this;
442  }

◆ operator=() [3/4]

template<int len>
Fstring& Gambit::Fstring< len >::operator= ( char  in)
inline

Definition at line 443 of file util_types.hpp.

444  {
446  for(int i=1; i<len; i++)
447  {
448  Farray<char,1,len>::array[i] = ' ';
449  }
450  return *this;
451  }

◆ operator=() [4/4]

template<int len>
template<int ilen>
Fstring& Gambit::Fstring< len >::operator= ( const Fstring< ilen > &  in)
inline

Definition at line 453 of file util_types.hpp.

References Gambit::Farray< char, 1, len >::array.

454  {
455  if (reinterpret_cast<const void*>(this) == reinterpret_cast<const void*>(&in)) return *this;
456  for(int i=0; i<len; i++)
457  {
458  Farray<char,1,len>::array[i] = (i<ilen) ? in.array[i] : ' ';
459  }
460  return *this;
461  }

◆ operator==()

template<int len>
bool Gambit::Fstring< len >::operator== ( std::string  str)
inline

Definition at line 479 of file util_types.hpp.

480  {
481  return this->trimmed_str() == str;
482  }
std::string str() const
Get std::string copy of the Fstring, including all trailing spaces.
Definition: util_types.hpp:463
std::string trimmed_str() const
Get std::string copy of the Fstring without trailing spaces.
Definition: util_types.hpp:468

◆ str()

template<int len>
std::string Gambit::Fstring< len >::str ( ) const
inline

Get std::string copy of the Fstring, including all trailing spaces.

Definition at line 463 of file util_types.hpp.

464  {
465  return std::string(Farray<char,1,len>::array,len);
466  }

◆ trimmed_str()

template<int len>
std::string Gambit::Fstring< len >::trimmed_str ( ) const
inline

Get std::string copy of the Fstring without trailing spaces.

Definition at line 468 of file util_types.hpp.

469  {
470  int idx;
471  for(int i=1; i<=len; i++)
472  {
473  idx=len-i;
474  if(Farray<char,1,len>::array[idx] != ' ') break;
475  }
476  return std::string(Farray<char,1,len>::array,idx+1);
477  }

The documentation for this class was generated from the following file: