$extrastylesheet
GETPOT_NAMESPACE::GetPot::variable Struct Reference

List of all members.

Public Member Functions

 variable ()
 variable (const variable &)
 variable (const char *Name, const char *Value, const char *FieldSeparator)
 ~variable ()
variableoperator= (const variable &Other)
void take (const char *Value, const char *FieldSeparator)
const std::string * get_element (unsigned Idx) const

Public Attributes

std::string name
STRING_VECTOR value
std::string original

Detailed Description

Variable to be specified on the command line or in input files. (i.e. of the form var='12 312 341')

Definition at line 415 of file getpot.h.


Constructor & Destructor Documentation

constructors, destructors, assignment operator

Definition at line 3739 of file getpot.h.

  : name(),
    value(),
    original()
{}

Definition at line 3748 of file getpot.h.

References GETPOT_NAMESPACE::GetPot::operator=().

{
#ifdef WIN32
  operator=(Other);
#else
  GetPot::variable::operator=(Other);
#endif
}
GETPOT_NAMESPACE::GetPot::variable::variable ( const char *  Name,
const char *  Value,
const char *  FieldSeparator 
) [inline]

Definition at line 3760 of file getpot.h.

References take().

  : name(Name)
{
  // make a copy of the 'Value'
  take(Value, FieldSeparator);
}

Definition at line 3835 of file getpot.h.

{}

Member Function Documentation

const std::string * GETPOT_NAMESPACE::GetPot::variable::get_element ( unsigned  Idx) const [inline]

get a specific element in the string vector (return 0 if not present)

Definition at line 3770 of file getpot.h.

Referenced by GETPOT_NAMESPACE::GetPot::get_value_no_default(), and GETPOT_NAMESPACE::GetPot::operator()().

{
  if (Idx >= value.size())
    return 0;
  else
    return &(value[Idx]);
}
GetPot::variable & GETPOT_NAMESPACE::GetPot::variable::operator= ( const variable Other) [inline]

Definition at line 3841 of file getpot.h.

References libMesh::Quality::name(), name, original, and value.

{
  if (&Other != this)
    {
      name     = Other.name;
      value    = Other.value;
      original = Other.original;
    }
  return *this;
}
void GETPOT_NAMESPACE::GetPot::variable::take ( const char *  Value,
const char *  FieldSeparator 
) [inline]

Definition at line 3781 of file getpot.h.

Referenced by variable().

{
  original = std::string(Value); // string member var
  value.clear();                 // vector<string> member var

  /*
  // separate string by white space delimiters using 'strtok'
  // thread safe usage of strtok (no static members)
  char* spt = 0;
  // make a copy of the 'Value'
  char* copy = new char[strlen(Value)+1];
  strcpy(copy, Value);
  char* follow_token = strtok_r(copy, FieldSeparator, &spt);
  while (follow_token != 0)
  {
  value.push_back(std::string(follow_token));
  follow_token = strtok_r(NULL, FieldSeparator, &spt);
  }

  delete [] copy;
  */

  // Don't use strtok, instead tokenize the input char "Value" using std::string operations so
  // that the results end up in the local "value" member

  // Construct std::string objects from the input char*s.  I think the only
  // FieldSeparator recognized by GetPot is whitespace?
  std::string Value_str = std::string(Value);
  std::string delimiters = std::string(FieldSeparator);

  // Skip delimiters at beginning.
  std::string::size_type lastPos = Value_str.find_first_not_of(delimiters, 0);

  // Find first "non-delimiter".
  std::string::size_type pos     = Value_str.find_first_of(delimiters, lastPos);

  // Loop over the input string until all the tokens have been pushed back
  // into the local "value" member.
  while (std::string::npos != pos || std::string::npos != lastPos)
    {
      // Found a token, add it to the vector.
      value.push_back(Value_str.substr(lastPos, pos - lastPos));

      // Skip delimiters.  Note the "not_of"
      lastPos = Value_str.find_first_not_of(delimiters, pos);

      // Find next "non-delimiter"
      pos = Value_str.find_first_of(delimiters, lastPos);
    }

  // We're done, all the tokens should now be in the vector<string>
}

Member Data Documentation

data memebers

Definition at line 437 of file getpot.h.

Referenced by GETPOT_NAMESPACE::GetPot::_DBE_expand(), and operator=().


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