MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mathtyp.h File Reference
#include <string>
#include "except.h"
Include dependency graph for mathtyp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TypedValue
 
class  TypedValue::ErrUnknownType
 
class  TypedValue::ErrWrongType
 
class  TypedValue::ErrUnknownValue
 
class  TypedValue::ErrConstraintViolation
 
class  NamedValue
 
class  Var
 

Typedefs

typedef double Real
 
typedef int Int
 

Functions

bool operator! (const TypedValue &v)
 
TypedValue operator- (const TypedValue &v)
 
TypedValue operator+ (const TypedValue &v)
 
std::ostream & operator<< (std::ostream &out, const TypedValue &v)
 

Typedef Documentation

typedef int Int

Definition at line 40 of file mathtyp.h.

typedef double Real

Definition at line 39 of file mathtyp.h.

Function Documentation

bool operator! ( const TypedValue v)

Definition at line 1657 of file mathp.cc.

References TypedValue::GetReal(), TypedValue::GetString(), TypedValue::GetType(), and TypedValue::VAR_STRING.

1658 {
1659  if (v.GetType() == TypedValue::VAR_STRING) {
1660  return v.GetString().empty();
1661  }
1662 
1663  return (!v.GetReal());
1664 }
Real GetReal(void) const
Definition: mathp.cc:1228
TypedValue::Type GetType(void) const
Definition: mathp.cc:1155
const std::string & GetString(void) const
Definition: mathp.cc:1247

Here is the call graph for this function:

TypedValue operator+ ( const TypedValue v)

Definition at line 1689 of file mathp.cc.

1690 {
1691  return v;
1692 }
TypedValue operator- ( const TypedValue v)

Definition at line 1667 of file mathp.cc.

References TypedValue::GetInt(), TypedValue::GetReal(), TypedValue::GetType(), MBDYN_EXCEPT_ARGS, TypedValue::VAR_BOOL, TypedValue::VAR_INT, TypedValue::VAR_REAL, and TypedValue::VAR_STRING.

1668 {
1669  switch (v.GetType()) {
1670  case TypedValue::VAR_BOOL:
1671  // bool is implicitly cast to Int
1672  case TypedValue::VAR_INT:
1673  return TypedValue(-v.GetInt());
1674 
1675  case TypedValue::VAR_REAL:
1676  return TypedValue(-v.GetReal());
1677 
1680 
1681  default:
1683  }
1684 
1685  return 0;
1686 }
Real GetReal(void) const
Definition: mathp.cc:1228
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
TypedValue::Type GetType(void) const
Definition: mathp.cc:1155
Int GetInt(void) const
Definition: mathp.cc:1209

Here is the call graph for this function:

std::ostream& operator<< ( std::ostream &  out,
const TypedValue v 
)

Definition at line 1695 of file mathp.cc.

References TypedValue::GetInt(), TypedValue::GetReal(), TypedValue::GetString(), TypedValue::GetType(), MBDYN_EXCEPT_ARGS, TypedValue::VAR_BOOL, TypedValue::VAR_INT, TypedValue::VAR_REAL, and TypedValue::VAR_STRING.

1696 {
1697  switch (v.GetType()) {
1698  case TypedValue::VAR_BOOL:
1699  case TypedValue::VAR_INT:
1700  return out << v.GetInt();
1701 
1702  case TypedValue::VAR_REAL: {
1703  // FIXME: precision?
1704  // make sure there is a (trailing) '.'
1705  std::ostringstream os;
1706  os << v.GetReal();
1707  if (os.str().find('.') == std::string::npos) {
1708  os << '.';
1709  }
1710  return out << os.str();
1711  }
1712 
1714  return out << '"' << v.GetString() << '"';
1715 
1716  default:
1718  }
1719 
1720  return out;
1721 }
Real GetReal(void) const
Definition: mathp.cc:1228
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
TypedValue::Type GetType(void) const
Definition: mathp.cc:1155
const std::string & GetString(void) const
Definition: mathp.cc:1247
Int GetInt(void) const
Definition: mathp.cc:1209

Here is the call graph for this function: