Goby v2
Public Types | Friends | List of all members
goby::transitional::DCCLMessageVal Class Reference

defines a DCCL value More...

#include <goby/moos/transitional/message_val.h>

Public Types

enum  { MAX_DBL_PRECISION = 15 }
 

Public Member Functions

Constructors/Destructor
 DCCLMessageVal ()
 empty
 
 DCCLMessageVal (const std::string &s)
 construct with string value
 
 DCCLMessageVal (const char *s)
 construct with char* value
 
 DCCLMessageVal (double d, int p=MAX_DBL_PRECISION)
 construct with double value, optionally givig the precision of the double (number of decimal places) which is used if a cast to std::string is required in the future.
 
 DCCLMessageVal (long l)
 construct with long value
 
 DCCLMessageVal (int i)
 construct with int value
 
 DCCLMessageVal (float f)
 construct with float value
 
 DCCLMessageVal (bool b)
 construct with bool value
 
 DCCLMessageVal (const std::vector< DCCLMessageVal > &vm)
 construct with vector
 
Setters
void set (std::string sval)
 set the value with a string (overwrites previous value regardless of type)
 
void set (double dval, int precision=MAX_DBL_PRECISION)
 set the value with a double (overwrites previous value regardless of type) More...
 
void set (long lval)
 set the value with a long (overwrites previous value regardless of type)
 
void set (bool bval)
 set the value with a bool (overwrites previous value regardless of type)
 
Getters
bool get (std::string &s) const
 extract as std::string (all reasonable casts are done) More...
 
bool get (bool &b) const
 extract as bool (all reasonable casts are done) More...
 
bool get (long &t) const
 extract as long (all reasonable casts are done) More...
 
bool get (double &d) const
 extract as double (all reasonable casts are done) More...
 
 operator double () const
 allows statements of the form More...
 
 operator bool () const
 allows statements of the form More...
 
 operator std::string () const
 allows statements of the form More...
 
 operator long () const
 allows statements of the form More...
 
 operator int () const
 allows statements of the form More...
 
 operator unsigned () const
 allows statements of the form More...
 
 operator float () const
 allows statements of the form More...
 
 operator std::vector< DCCLMessageVal > () const
 
DCCLCppType type () const
 what type is the original type of this DCCLMessageVal?
 
bool empty () const
 was this just constructed with DCCLMessageVal() ?
 
unsigned precision () const
 
Comparison
bool operator== (const DCCLMessageVal &mv) const
 
bool operator== (const std::string &s) const
 
bool operator== (double d) const
 
bool operator== (long l) const
 
bool operator== (bool b) const
 

Friends

std::ostream & operator<< (std::ostream &os, const DCCLMessageVal &mv)
 

Detailed Description

defines a DCCL value

Definition at line 35 of file message_val.h.

Member Function Documentation

bool goby::transitional::DCCLMessageVal::get ( std::string &  s) const

extract as std::string (all reasonable casts are done)

Parameters
sstd::string to store value in
Returns
successfully extracted (and if necessary successfully cast to this type)

Definition at line 132 of file message_val.cpp.

bool goby::transitional::DCCLMessageVal::get ( bool b) const

extract as bool (all reasonable casts are done)

Parameters
bbool to store value in
Returns
successfully extracted (and if necessary successfully cast to this type)

Definition at line 156 of file message_val.cpp.

bool goby::transitional::DCCLMessageVal::get ( long &  t) const

extract as long (all reasonable casts are done)

Parameters
tlong to store value in
Returns
successfully extracted (and if necessary successfully cast to this type)

Definition at line 197 of file message_val.cpp.

bool goby::transitional::DCCLMessageVal::get ( double d) const

extract as double (all reasonable casts are done)

Parameters
ddouble to store value in
Returns
successfully extracted (and if necessary successfully cast to this type)

Definition at line 237 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator bool ( ) const

allows statements of the form

bool b = DCCLMessageVal("1");

Definition at line 285 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator double ( ) const

allows statements of the form

double d = DCCLMessageVal("3.23");

Definition at line 276 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator float ( ) const

allows statements of the form

float f = DCCLMessageVal("3.5");

Definition at line 316 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator int ( ) const

allows statements of the form

int i = DCCLMessageVal(2);

Definition at line 312 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator long ( ) const

allows statements of the form

long l = DCCLMessageVal(5);

Definition at line 303 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator std::string ( ) const

allows statements of the form

std::string s = DCCLMessageVal(3);

Definition at line 294 of file message_val.cpp.

goby::transitional::DCCLMessageVal::operator unsigned ( ) const

allows statements of the form

unsigned u = DCCLMessageVal(2);

Definition at line 314 of file message_val.cpp.

void goby::transitional::DCCLMessageVal::set ( double  dval,
int  precision = MAX_DBL_PRECISION 
)

set the value with a double (overwrites previous value regardless of type)

Parameters
dvalvalues to set
precisiondecimal places of precision to preserve if this is cast to a string

Definition at line 115 of file message_val.cpp.


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