Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::Angle Class Reference

Handles angle measurements by adding a 'unit' attribute to numeric values, or a character suffix in a string value. */. More...

#include <plistSpecialty.h>

Inheritance diagram for plist::Angle:

Detailed Description

Handles angle measurements by adding a 'unit' attribute to numeric values, or a character suffix in a string value. */.

Values are always stored in radians, but may be converted from/to degrees when loading/saving.

Valid values for a 'unit' attribute are: rad, radian, radians, °, deg, degree, degrees, π, pi, %, percent.

Valid values for a suffix are: °, π, π/, %. The 'π/' should be followed by another number to form a fraction, e.g. '3π/2' or 'π/3'.

To conform completely to Apple's plist specification, the 'unit' attribute should be avoided, and unit suffixes should only be used in 'string' elements. This code can handle both, but other editors might not. Use of the setPedantic() function can give a warning when such values are loaded, and rely on solely on strings for non-radian values.

Definition at line 114 of file plistSpecialty.h.

List of all members.

Public Types

enum  Format {
  FORMAT_NONE, FORMAT_RADIAN, FORMAT_DEGREE, FORMAT_PI,
  FORMAT_PERCENT, FORMAT_SAME, FORMAT_AUTO
}
enum  Pedantic { PEDANTIC_FULL, PEDANTIC_VALID, PEDANTIC_CUTE }

Public Member Functions

 Angle ()
 constructor
 Angle (PLISTREAL v)
 casting constructor
Angleoperator= (const std::string &v)
 assignment from std::string, wraps it in a plist::Primitive and passes on to operator=(PrimitiveBase)
void loadXML (xmlNode *node)
 interprets node as holding the specialization type
void saveXML (xmlNode *node) const
 saves val into node
void set (const std::string &str)
 assign a new value
void setDegree (PLISTREAL v)
PLISTREAL getDegree () const
std::string get () const
 return current value as a string
void setFormat (Format fmt)
 sets saveFormat
Format getFormat () const
 returns saveFormat
Format getLoadedFormat () const
virtual Angleclone () const __attribute__((warn_unused_result))
 clone definition for Angle

Static Public Member Functions

static void setDefaultFormat (Format fmt)
 sets defaultFormat
static Format getDefaultFormat ()
 returns defaultFormat
static void setPedantic (Pedantic p)
 sets pedantic
static Pedantic getPedantic ()
 returns pedantic

Protected Member Functions

void parseRadian (const std::string &str)

Protected Attributes

Format saveFormat
 Specifies what format we should save in.
Format loadedFormat
 Specifies the format last loaded (to be reused if saveFormat is FORMAT_SAME).

Static Protected Attributes

static Format defaultFormat = Angle::FORMAT_DEGREE
 The format to use if loadedFormat is FORMAT_AUTO;.
static Pedantic pedantic = Angle::PEDANTIC_FULL
 If true, saved elements will use 'string' instead of 'real' with an element, and warnings will be issued.

Member Enumeration Documentation

Enumerator:
FORMAT_NONE 

value will be in radians, but no unit will be specified

FORMAT_RADIAN 

value will be in radians

FORMAT_DEGREE 

value will be in degrees

FORMAT_PI 

value will be multiple of pi

FORMAT_PERCENT 

value will be a percentage of a circle

FORMAT_SAME 

use same units that was loaded, or 'auto' if not loaded

FORMAT_AUTO 

uses degrees if value works out to be a integer, or raw radian otherwise

Definition at line 116 of file plistSpecialty.h.

Enumerator:
PEDANTIC_FULL 

uses 'string' elements for plist compliance, though less intuitive since these are really numeric values

PEDANTIC_VALID 

uses a 'unit' attribute on the value element to specify the units... may be stripped by editor, but validates

PEDANTIC_CUTE 

uses a 'real' element, regardless of presence of suffix... editor may refuse to open due to non-numeric characters

Definition at line 126 of file plistSpecialty.h.


Constructor & Destructor Documentation

plist::Angle::Angle (  ) 

constructor

Definition at line 132 of file plistSpecialty.h.

plist::Angle::Angle ( PLISTREAL  v  ) 

casting constructor

Definition at line 133 of file plistSpecialty.h.


Member Function Documentation

Angle * plist::Angle::clone (  )  const [virtual]

clone definition for Angle

implements the clone function for Primitive<char>

Reimplemented from plist::Primitive< PLISTREAL >.

Definition at line 656 of file plistSpecialty.cc.

std::string plist::Angle::get (  )  const [virtual]

return current value as a string

Reimplemented from plist::Primitive< PLISTREAL >.

Definition at line 598 of file plistSpecialty.cc.

static Format plist::Angle::getDefaultFormat (  )  [static]

returns defaultFormat

Definition at line 150 of file plistSpecialty.h.

PLISTREAL plist::Angle::getDegree (  )  const

Definition at line 142 of file plistSpecialty.h.

Format plist::Angle::getFormat (  )  const

returns saveFormat

Definition at line 146 of file plistSpecialty.h.

Format plist::Angle::getLoadedFormat (  )  const

Definition at line 147 of file plistSpecialty.h.

static Pedantic plist::Angle::getPedantic (  )  [static]

returns pedantic

Definition at line 153 of file plistSpecialty.h.

void plist::Angle::loadXML ( xmlNode node  )  [virtual]

interprets node as holding the specialization type

Reimplemented from plist::Primitive< PLISTREAL >.

Definition at line 374 of file plistSpecialty.cc.

Angle& plist::Angle::operator= ( const std::string &  v  ) 

assignment from std::string, wraps it in a plist::Primitive and passes on to operator=(PrimitiveBase)

Reimplemented from plist::PrimitiveBase.

Definition at line 134 of file plistSpecialty.h.

Referenced by setDegree().

void plist::Angle::parseRadian ( const std::string &  str  )  [protected]
void plist::Angle::saveXML ( xmlNode node  )  const [virtual]

saves val into node

Reimplemented from plist::Primitive< PLISTREAL >.

Definition at line 442 of file plistSpecialty.cc.

void plist::Angle::set ( const std::string &  str  )  [virtual]

assign a new value

Reimplemented from plist::Primitive< PLISTREAL >.

Definition at line 507 of file plistSpecialty.cc.

static void plist::Angle::setDefaultFormat ( Format  fmt  )  [static]

sets defaultFormat

Definition at line 149 of file plistSpecialty.h.

void plist::Angle::setDegree ( PLISTREAL  v  ) 

Definition at line 141 of file plistSpecialty.h.

void plist::Angle::setFormat ( Format  fmt  ) 

sets saveFormat

Definition at line 145 of file plistSpecialty.h.

Referenced by KinematicJoint::plistValueChanged().

static void plist::Angle::setPedantic ( Pedantic  p  )  [static]

sets pedantic

Definition at line 152 of file plistSpecialty.h.


Member Data Documentation

Angle::Format plist::Angle::defaultFormat = Angle::FORMAT_DEGREE [static, protected]

The format to use if loadedFormat is FORMAT_AUTO;.

Definition at line 165 of file plistSpecialty.h.

Referenced by get(), getDefaultFormat(), saveXML(), and setDefaultFormat().

Specifies the format last loaded (to be reused if saveFormat is FORMAT_SAME).

Definition at line 163 of file plistSpecialty.h.

Referenced by get(), getLoadedFormat(), loadXML(), saveXML(), and set().

Angle::Pedantic plist::Angle::pedantic = Angle::PEDANTIC_FULL [static, protected]

If true, saved elements will use 'string' instead of 'real' with an element, and warnings will be issued.

Definition at line 167 of file plistSpecialty.h.

Referenced by getPedantic(), saveXML(), and setPedantic().

Specifies what format we should save in.

Definition at line 161 of file plistSpecialty.h.

Referenced by get(), getFormat(), saveXML(), and setFormat().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:25 2016 by Doxygen 1.6.3