reSIProcate/stack  9694
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
resip::DataParameter Class Reference

Generically represents miscellaneous parameter data. More...

#include <DataParameter.hxx>

Inheritance diagram for resip::DataParameter:
Inheritance graph
[legend]
Collaboration diagram for resip::DataParameter:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Data Type

Public Member Functions

 DataParameter (ParameterTypes::Type, ParseBuffer &pb, const std::bitset< 256 > &terminators)
 DataParameter (ParameterTypes::Type)
bool isQuoted () const
void setQuoted (bool b)
virtual Parameterclone () const
virtual EncodeStreamencode (EncodeStream &stream) const
Typevalue ()

Static Public Member Functions

static Parameterdecode (ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)

Protected Member Functions

 DataParameter (const DataParameter &other)

Protected Attributes

Type mValue
bool mQuoted

Detailed Description

Generically represents miscellaneous parameter data.

Definition at line 20 of file DataParameter.hxx.


Member Typedef Documentation

Definition at line 23 of file DataParameter.hxx.


Constructor & Destructor Documentation

DataParameter::DataParameter ( ParameterTypes::Type  type,
ParseBuffer pb,
const std::bitset< 256 > &  terminators 
)

Definition at line 18 of file DataParameter.cxx.

References resip::ParseBuffer::data(), resip::Symbols::DOUBLE_QUOTE, resip::Data::empty(), resip::Symbols::EQUALS, mQuoted, mValue, resip::ParseBuffer::position(), setQuoted(), resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipToEndQuote(), resip::ParseBuffer::skipToOneOf(), and resip::ParseBuffer::skipWhitespace().

Referenced by clone(), and decode().

   : Parameter(type), 
     mValue(),
     mQuoted(false)
{
   pb.skipWhitespace();
   pb.skipChar(Symbols::EQUALS[0]);
   pb.skipWhitespace();
   if(terminators[(unsigned char)(*pb.position())]) // handle cases such as ;tag=
   {
      throw ParseException("Empty value in string-type parameter.",
                              "DataParameter",
                              __FILE__,__LINE__);
   }

   if (*pb.position() == Symbols::DOUBLE_QUOTE[0])
   {
      setQuoted(true);
      pb.skipChar();
      const char* pos = pb.position();
      pb.skipToEndQuote();
      pb.data(mValue, pos);
      pb.skipChar();
   }
   else
   {
      const char* pos = pb.position();
      pb.skipToOneOf(terminators);
      pb.data(mValue, pos);
   }

   if(!mQuoted && mValue.empty())
   {
      // .bwc. We can't let this happen, because we throw if we try to encode
      // when we have an empty value. If that behavior stops, this can be 
      // removed.
     /* throw ParseException("DataParameter c'tor parsed empty param!", 
                           "DataParameter",
                           __FILE__,
                           __LINE__); */
   }
}

Here is the call graph for this function:

DataParameter::DataParameter ( ParameterTypes::Type  type) [explicit]

Definition at line 63 of file DataParameter.cxx.

   : Parameter(type),
     mValue(),
     mQuoted(false)
{
}
resip::DataParameter::DataParameter ( const DataParameter other) [inline, protected]

Definition at line 45 of file DataParameter.hxx.

         : Parameter(other), 
           mValue(other.mValue), 
           mQuoted(other.mQuoted)
      {
      }

Member Function Documentation

Parameter * DataParameter::clone ( ) const [virtual]

Implements resip::Parameter.

Reimplemented in resip::QuotedDataParameter, and resip::ExistsOrDataParameter.

Definition at line 71 of file DataParameter.cxx.

References DataParameter().

{
   return new DataParameter(*this);
}

Here is the call graph for this function:

static Parameter* resip::DataParameter::decode ( ParameterTypes::Type  type,
ParseBuffer pb,
const std::bitset< 256 > &  terminators,
PoolBase pool 
) [inline, static]

Reimplemented in resip::QuotedDataParameter, and resip::ExistsOrDataParameter.

Definition at line 32 of file DataParameter.hxx.

References DataParameter().

      {
         return new (pool) DataParameter(type, pb, terminators);
      }

Here is the call graph for this function:

EncodeStream & DataParameter::encode ( EncodeStream stream) const [virtual]

Implements resip::Parameter.

Reimplemented in resip::ExistsOrDataParameter.

Definition at line 77 of file DataParameter.cxx.

References resip::Symbols::DOUBLE_QUOTE, resip::Data::empty(), resip::Symbols::EQUALS, ErrLog, resip::Parameter::getName(), mQuoted, and mValue.

{
   if (mQuoted)
   {
      return stream << getName() << Symbols::EQUALS 
                    << Symbols::DOUBLE_QUOTE << mValue << Symbols::DOUBLE_QUOTE;
   }
   else
   {
      // this will assert if you've accessed a parameter that doesn't exist and
      // then the stack has created an empty parameter with no value. Try
      // calling exists(p_foo) before calling param(p_foo)
      if (mValue.empty())
      {
         ErrLog(<< "Accessing defaulted DataParameter: '" << getName() << "'");
      }
      assert(!mValue.empty()); // !jf!  probably should throw here
      return stream << getName() << Symbols::EQUALS << mValue;
   }
}

Here is the call graph for this function:

bool resip::DataParameter::isQuoted ( ) const [inline, virtual]

Reimplemented from resip::Parameter.

Definition at line 29 of file DataParameter.hxx.

References mQuoted.

{ return mQuoted; }
void resip::DataParameter::setQuoted ( bool  b) [inline, virtual]

Reimplemented from resip::Parameter.

Definition at line 30 of file DataParameter.hxx.

References mQuoted.

Referenced by resip::Auth::createParam(), and DataParameter().

{ mQuoted = b; }; // this parameter will be enclosed in quotes e.g. "foo"
Type& resip::DataParameter::value ( ) [inline]

Definition at line 43 of file DataParameter.hxx.

References mValue.

Referenced by resip::ParserCategory::encodeParameters().

{return mValue;}            // does not return a quoted string

Member Data Documentation


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