vValue::Expr::Core::Base Class Reference

Offers basic functions to set the precision etc. More...

#include <vCore.h>

Inheritance diagram for vValue::Expr::Core::Base:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Base (int precision=1, int minsize=0, char fill='0')
 Default constructor.
 Base (Base const &other)
 Copy constructor.
virtual ~Base ()
virtual Basecopy (void) const
 Returns an exact copy of this object.
virtual int GetInt (void) const
 Returns an integer using the current value.
virtual float GetFloat (void) const
 Returns a float using the current value.
virtual tString GetString (Base const *other=0) const
 Returns a String using the current value using Output().
virtual Variant GetValue (void) const
 Returns the value in its native format.
template<class T>
Get () const
void SetPrecision (int precision)
 Sets the precision when outputting a string.
void SetMinsize (int size)
 Sets the minimal width when outputting a string.
void SetFill (char fill)
 Sets the fill character when outputting a string shorter than the minimal width.
 operator int () const
 operator float () const
 operator tString () const
virtual bool operator== (Base const &other) const
 compares two values
virtual bool operator!= (Base const &other) const
 compares two values
virtual bool operator>= (Base const &other) const
 compares two values
virtual bool operator<= (Base const &other) const
 compares two values
virtual bool operator> (Base const &other) const
 compares two values
virtual bool operator< (Base const &other) const
 compares two values

Protected Member Functions

template<typename T>
tString Output (T value, Base const *other=0) const
 Converts a value to a string using the settings like precision etc.

Private Attributes

int m_precision
 The precision when returning a string.
int m_minsize
 The minimum width when returning a string.
char m_fill
 The fill character that's used when the contents are too small to fill m_minsize.


Detailed Description

Offers basic functions to set the precision etc.

Definition at line 58 of file vCore.h.


Constructor & Destructor Documentation

vValue::Expr::Core::Base::Base ( int  precision = 1,
int  minsize = 0,
char  fill = '0' 
)

Default constructor.

Parameters:
precision the number of digits after the decimal to be used when outputting a string
minsize the minimum width when outputting a string
fill the character used to fill when outputting a string and the size of the output is smaller than minsize

Definition at line 39 of file vCore.cpp.

Referenced by copy().

00039                                                :
00040         m_precision(precision),
00041         m_minsize(minsize),
00042         m_fill(fill)
00043 {}

Here is the caller graph for this function:

vValue::Expr::Core::Base::Base ( Base const &  other  ) 

Copy constructor.

This will drop all value information of other and create a dummy- class (except if it's called from the parameter initialisation list of a derived class)

Parameters:
other another Base or derived class

Definition at line 47 of file vCore.cpp.

00047                             :
00048         m_precision(other.m_precision),
00049         m_minsize(other.m_minsize),
00050         m_fill(other.m_fill)
00051 { }

virtual vValue::Expr::Core::Base::~Base (  )  [inline, virtual]

Definition at line 69 of file vCore.h.

00069 { };


Member Function Documentation

template<typename T>
tString vValue::Expr::Core::Base::Output ( value,
Base const *  other = 0 
) const [inline, protected]

Converts a value to a string using the settings like precision etc.

Returns a string using the settings from this or another object.

This function is inline even though its size since it gets called extemely often from the derived classes.

Parameters:
value the value to be converted and returned
other pointer to the class that contains the settings, if it is 0 the settings will be taken from the class the function was called for
Returns:
the resulting string

Definition at line 103 of file vCore.h.

References m_fill, m_minsize, and m_precision.

Referenced by vValue::Expr::Bindings::Legacy::ConfItem::GetString(), vValue::Expr::Core::Number< T >::GetString(), vValue::Expr::Core::String::GetString(), and GetString().

00103                                                                                  {
00104     if (other==0) other=this;
00105     std::ostringstream buf("");
00106     buf << std::setfill(other->m_fill) << std::setw(other->m_minsize) << std::fixed << std::setprecision(other->m_precision) << value; return buf.str();
00107 }

Here is the caller graph for this function:

Base * vValue::Expr::Core::Base::copy ( void   )  const [virtual]

Returns an exact copy of this object.

This should be overwritten in any derived class or they will mysteriously vanish if you use the tValue::Set container, for example

Returns:
a pointer to the newly created copy

Reimplemented in vValue::Expr::Collection::BaseExt, vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColPickOne, vValue::Expr::Collection::ColBinary, vValue::Expr::Collection::ColUnion, vValue::Expr::Collection::ColIntersection, vValue::Expr::Collection::ColDifference, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Core::UnaryOp, vValue::Expr::Core::BinaryOp, vValue::Expr::Bindings::Legacy::Callback< T >, vValue::Expr::Bindings::Legacy::ConfItem, vValue::Expr::Bindings::MathExpr, vValue::Expr::Logic::Condition, vValue::Expr::Math::Add, vValue::Expr::Math::Subtract, vValue::Expr::Math::Multiply, and vValue::Expr::Math::Divide.

Definition at line 116 of file vCore.cpp.

References Base().

Referenced by vValue::Type::Set::operator=().

00116                            {
00117     return new Base();
00118 }

Here is the call graph for this function:

Here is the caller graph for this function:

int vValue::Expr::Core::Base::GetInt ( void   )  const [virtual]

Returns an integer using the current value.

This should be overwritten in a derived class if it's sensible to convert the value to an integer

Returns:
0

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 80 of file vCore.cpp.

References GetValue().

Referenced by vValue::Expr::Logic::Condition::GetInt(), and operator int().

00080                            {
00081     try {
00082         return boost::lexical_cast<int>(GetValue());
00083     }
00084     catch(boost::bad_lexical_cast &)
00085     {
00086         return 0;
00087     }
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

float vValue::Expr::Core::Base::GetFloat ( void   )  const [virtual]

Returns a float using the current value.

This should be overwritten in a derived class if it's sensible to convert the value to a floating- point number

Returns:
a stream conversion of the value

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 93 of file vCore.cpp.

References GetValue().

Referenced by vValue::Expr::Logic::Condition::GetFloat(), operator float(), and cWidget::BarGauge::Render().

00093                                {
00094     try {
00095         return boost::lexical_cast<float>(GetValue());
00096     }
00097     catch(boost::bad_lexical_cast &)
00098     {
00099         return 0.0;
00100     }
00101 }

Here is the call graph for this function:

Here is the caller graph for this function:

tString vValue::Expr::Core::Base::GetString ( Base const *  other = 0  )  const [virtual]

Returns a String using the current value using Output().

This should be overwritten in a derived class if it's sensible to convert the value to a string

Returns:
GetValue streamed to a tString

Reimplemented in vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, vValue::Expr::Bindings::Legacy::ConfItem, and vValue::Expr::Logic::Condition.

Definition at line 106 of file vCore.cpp.

References GetValue(), and Output().

Referenced by vValue::Expr::Logic::Condition::GetString(), operator tString(), cWidget::NeedleGauge::RenderGraph(), cWidget::VerticalBarGauge::RenderGraph(), and cWidget::BarGauge::RenderGraph().

00106                                                {
00107     Variant v = GetValue();
00108     if (tString *iptr = boost::get<tString>(&v))
00109             return *iptr;
00110     return Output(v, other);
00111 }

Here is the call graph for this function:

Here is the caller graph for this function:

Variant vValue::Expr::Core::Base::GetValue ( void   )  const [virtual]

Returns the value in its native format.

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::CFunction::fZeroary< T, F >, vValue::Expr::Bindings::CFunction::fUnary< T, Aa, F >, vValue::Expr::Bindings::CFunction::fBinary< T, Aa, Ab, F >, vValue::Expr::Bindings::Legacy::Callback< T >, vValue::Expr::Bindings::Legacy::ConfItem, vValue::Expr::Bindings::MathExpr, vValue::Expr::Logic::Condition, vValue::Expr::Math::Add, vValue::Expr::Math::Subtract, vValue::Expr::Math::Multiply, and vValue::Expr::Math::Divide.

Definition at line 72 of file vCore.cpp.

Referenced by display_cockpit_lucifer(), GetFloat(), GetInt(), GetString(), and vValue::Expr::Logic::Condition::GetValue().

00072                          {
00073     //std::cerr << "WARNING: Base::GetValue called!" << std::endl;
00074     return std::string("");
00075 }

Here is the caller graph for this function:

tString vValue::Expr::Core::Base::Get< tString > ( void   )  const [inline]

void vValue::Expr::Core::Base::SetPrecision ( int  precision  ) 

Sets the precision when outputting a string.

Sets m_precision to the given value

Parameters:
precision the number of digits after the decimal to be displayed

Definition at line 55 of file vCore.cpp.

References m_precision.

Referenced by cWidget::WithDataFunctions::ProcessDataTags().

00055                                      {
00056     m_precision = precision;
00057 }

Here is the caller graph for this function:

void vValue::Expr::Core::Base::SetMinsize ( int  minsize  ) 

Sets the minimal width when outputting a string.

Sets m_minsize to the given value

Parameters:
minsize the minimal width of the outputted string in # of characters

Definition at line 61 of file vCore.cpp.

References m_minsize.

Referenced by cWidget::WithDataFunctions::ProcessDataTags().

00061                                  {
00062     m_minsize = minsize;
00063 }

Here is the caller graph for this function:

void vValue::Expr::Core::Base::SetFill ( char  fill  ) 

Sets the fill character when outputting a string shorter than the minimal width.

Sets m_fill to the given value

Parameters:
fill the character to be used to fill

Definition at line 67 of file vCore.cpp.

References m_fill.

Referenced by cWidget::WithDataFunctions::ProcessDataTags().

00067                             {
00068     m_fill = fill;
00069 }

Here is the caller graph for this function:

vValue::Expr::Core::Base::operator int (  )  const [inline]

Definition at line 84 of file vCore.h.

References GetInt().

00084 { return GetInt(); }

Here is the call graph for this function:

vValue::Expr::Core::Base::operator float (  )  const [inline]

Definition at line 85 of file vCore.h.

References GetFloat().

00085 { return GetFloat(); }

Here is the call graph for this function:

vValue::Expr::Core::Base::operator tString (  )  const [inline]

Definition at line 86 of file vCore.h.

References GetString().

00086 { return GetString(); }

Here is the call graph for this function:

bool vValue::Expr::Core::Base::operator== ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 120 of file vCore.cpp.

00120 { return false; }

bool vValue::Expr::Core::Base::operator!= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 121 of file vCore.cpp.

00121 { return true;  }

bool vValue::Expr::Core::Base::operator>= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 122 of file vCore.cpp.

00122 { return false; }

bool vValue::Expr::Core::Base::operator<= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 123 of file vCore.cpp.

00123 { return false; }

bool vValue::Expr::Core::Base::operator> ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 124 of file vCore.cpp.

00124 { return false; }

bool vValue::Expr::Core::Base::operator< ( Base const &  other  )  const [virtual]

compares two values

Reimplemented in vValue::Expr::Collection::ColNode, vValue::Expr::Collection::ColUnary, vValue::Expr::Collection::ColBinary, vValue::Expr::Core::Number< T >, vValue::Expr::Core::String, vValue::Expr::Bindings::Legacy::Callback< T >, and vValue::Expr::Logic::Condition.

Definition at line 125 of file vCore.cpp.

00125 { return false; }


Member Data Documentation

int vValue::Expr::Core::Base::m_precision [private]

The precision when returning a string.

Definition at line 59 of file vCore.h.

Referenced by Output(), and SetPrecision().

int vValue::Expr::Core::Base::m_minsize [private]

The minimum width when returning a string.

Definition at line 60 of file vCore.h.

Referenced by Output(), and SetMinsize().

char vValue::Expr::Core::Base::m_fill [private]

The fill character that's used when the contents are too small to fill m_minsize.

Definition at line 61 of file vCore.h.

Referenced by Output(), and SetFill().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:05:49 2008 for Armagetron Advanced by  doxygen 1.5.4