OpenMAMA
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
price.h File Reference
#include <mama/config.h>
#include <mama/status.h>
#include <mama/types.h>

Go to the source code of this file.

Macros

#define MAMA_PRICE_HINTS_NONE   ((mamaPriceHints)0x00)
 
#define MAMA_PRICE_MAX_STR_LEN   (32)
 
#define MAMA_PRICE_EPSILON   ((mama_f64_t)0.00000000001)
 MAMA_PRICE_EPSILON a value that is considered equivalent to zero. More...
 

Typedefs

typedef enum mamaPricePrecision_ mamaPricePrecision
 
typedef mama_u8_t mamaPriceHints
 

Enumerations

enum  mamaPricePrecision_ {
  MAMA_PRICE_PREC_UNKNOWN = 0, MAMA_PRICE_PREC_10 = 1, MAMA_PRICE_PREC_100 = 2, MAMA_PRICE_PREC_1000 = 3,
  MAMA_PRICE_PREC_10000 = 4, MAMA_PRICE_PREC_100000 = 5, MAMA_PRICE_PREC_1000000 = 6, MAMA_PRICE_PREC_10000000 = 7,
  MAMA_PRICE_PREC_100000000 = 8, MAMA_PRICE_PREC_1000000000 = 9, MAMA_PRICE_PREC_10000000000 = 10, MAMA_PRICE_PREC_INT = 16,
  MAMA_PRICE_PREC_DIV_2 = 17, MAMA_PRICE_PREC_DIV_4 = 18, MAMA_PRICE_PREC_DIV_8 = 19, MAMA_PRICE_PREC_DIV_16 = 20,
  MAMA_PRICE_PREC_DIV_32 = 21, MAMA_PRICE_PREC_DIV_64 = 22, MAMA_PRICE_PREC_DIV_128 = 23, MAMA_PRICE_PREC_DIV_256 = 24,
  MAMA_PRICE_PREC_DIV_512 = 25, MAMA_PRICE_PREC_TICK_32 = 26, MAMA_PRICE_PREC_HALF_32 = 27, MAMA_PRICE_PREC_QUARTER_32 = 28,
  MAMA_PRICE_PREC_TICK_64 = 29, MAMA_PRICE_PREC_HALF_64 = 30, MAMA_PRICE_PREC_CENTS = MAMA_PRICE_PREC_100, MAMA_PRICE_PREC_PENNIES = MAMA_PRICE_PREC_100
}
 

Functions

MAMAExpDLL mama_status mamaPrice_create (mamaPrice *price)
 Create a mamaPrice object. More...
 
MAMAExpDLL mama_status mamaPrice_destroy (mamaPrice price)
 Destroy a mamaPrice object. More...
 
MAMAExpDLL mama_status mamaPrice_clear (mamaPrice price)
 Clear a mamaPrice object. More...
 
MAMAExpDLL mama_status mamaPrice_copy (mamaPrice dest, const mamaPrice src)
 Copy a price object. More...
 
MAMAExpDLL mama_status mamaPrice_add (mamaPrice dest, const mamaPrice rhs)
 Add to a price object. More...
 
MAMAExpDLL mama_status mamaPrice_subtract (mamaPrice dest, const mamaPrice rhs)
 Subtract from a price object. More...
 
MAMAExpDLL int mamaPrice_equal (const mamaPrice lhs, const mamaPrice rhs)
 Check for equality between two price objects. More...
 
MAMAExpDLL double mamaPrice_compare (const mamaPrice lhs, const mamaPrice rhs)
 Compare two price objects. More...
 
MAMAExpDLL mama_status mamaPrice_setValue (mamaPrice price, double value)
 Set the price value only (no hint information). More...
 
MAMAExpDLL mama_status mamaPrice_setPrecision (mamaPrice price, mamaPricePrecision precision)
 Set the price precision. More...
 
MAMAExpDLL mama_status mamaPrice_setIsValidPrice (mamaPrice price, mama_bool_t valid)
 Set if price contains a valid value. More...
 
MAMAExpDLL mama_status mamaPrice_setHints (mamaPrice price, mamaPriceHints hints)
 Set all of the price hints. More...
 
MAMAExpDLL mama_status mamaPrice_setWithHints (mamaPrice price, double value, mamaPriceHints hints)
 Set the price with hint information. More...
 
MAMAExpDLL mama_status mamaPrice_setFromString (mamaPrice price, const char *str)
 Set the price from a string representation, preserving any detectable hints. More...
 
MAMAExpDLL mama_status mamaPrice_getValue (const mamaPrice price, double *value)
 Get the price value only. More...
 
MAMAExpDLL mama_status mamaPrice_getRoundedValue (const mamaPrice price, const mamaPricePrecision precision, double *value)
 This function obtains the double value of a price rounded to the supplied precision. More...
 
MAMAExpDLL mama_status mamaPrice_getPrecision (const mamaPrice price, mamaPricePrecision *precision)
 Get the price precision. More...
 
MAMAExpDLL mama_status mamaPrice_getIsValidPrice (const mamaPrice price, mama_bool_t *valid)
 Check if price contains a valid value. More...
 
MAMAExpDLL mama_status mamaPrice_getHints (const mamaPrice price, mamaPriceHints *hints)
 Get the price hints. More...
 
MAMAExpDLL mama_status mamaPrice_getWithHints (const mamaPrice price, double *value, mamaPricePrecision *precision)
 Get the price with special, optional hints. More...
 
MAMAExpDLL mama_status mamaPrice_getAsString (const mamaPrice price, char *str, mama_size_t maxLen)
 Get the price as a string, formatted according to the hints provided. More...
 
MAMAExpDLL mama_status mamaPrice_negate (mamaPrice price)
 Negate the price value. More...
 
MAMAExpDLL mama_status mamaPrice_isZero (const mamaPrice price, mama_bool_t *result)
 Return whether the price has a value equivalent to zero. More...
 
MAMAExpDLL mamaPricePrecision mamaPrice_decimals2Precision (mama_i32_t places)
 Return the appropriate precision code for a given number of decimal places. More...
 
MAMAExpDLL mamaPricePrecision mamaPrice_denom2Precision (mama_i32_t denominator)
 Return the appropriate precision code for a given fractional denominator. More...
 
MAMAExpDLL mama_i32_t mamaPrice_precision2Decimals (mamaPricePrecision precision)
 Return the number of decimal places for a given precision code. More...
 
MAMAExpDLL mama_i32_t mamaPrice_precision2Denom (mamaPricePrecision precision)
 Return the fractional denominator for a given precision code. More...
 

Macro Definition Documentation

#define MAMA_PRICE_HINTS_NONE   ((mamaPriceHints)0x00)
#define MAMA_PRICE_MAX_STR_LEN   (32)
#define MAMA_PRICE_EPSILON   ((mama_f64_t)0.00000000001)

MAMA_PRICE_EPSILON a value that is considered equivalent to zero.

Typedef Documentation

Enumeration Type Documentation

Enumerator
MAMA_PRICE_PREC_UNKNOWN 
MAMA_PRICE_PREC_10 
MAMA_PRICE_PREC_100 
MAMA_PRICE_PREC_1000 
MAMA_PRICE_PREC_10000 
MAMA_PRICE_PREC_100000 
MAMA_PRICE_PREC_1000000 
MAMA_PRICE_PREC_10000000 
MAMA_PRICE_PREC_100000000 
MAMA_PRICE_PREC_1000000000 
MAMA_PRICE_PREC_10000000000 
MAMA_PRICE_PREC_INT 
MAMA_PRICE_PREC_DIV_2 
MAMA_PRICE_PREC_DIV_4 
MAMA_PRICE_PREC_DIV_8 
MAMA_PRICE_PREC_DIV_16 
MAMA_PRICE_PREC_DIV_32 
MAMA_PRICE_PREC_DIV_64 
MAMA_PRICE_PREC_DIV_128 
MAMA_PRICE_PREC_DIV_256 
MAMA_PRICE_PREC_DIV_512 
MAMA_PRICE_PREC_TICK_32 
MAMA_PRICE_PREC_HALF_32 
MAMA_PRICE_PREC_QUARTER_32 
MAMA_PRICE_PREC_TICK_64 
MAMA_PRICE_PREC_HALF_64 
MAMA_PRICE_PREC_CENTS 
MAMA_PRICE_PREC_PENNIES 

Function Documentation

MAMAExpDLL mama_status mamaPrice_create ( mamaPrice price)

Create a mamaPrice object.

Parameters
priceThe location of a mamaPrice where to store the result.
MAMAExpDLL mama_status mamaPrice_destroy ( mamaPrice  price)

Destroy a mamaPrice object.

Parameters
priceThe price object to destroy.
MAMAExpDLL mama_status mamaPrice_clear ( mamaPrice  price)

Clear a mamaPrice object.

Parameters
priceThe price object to clear.
MAMAExpDLL mama_status mamaPrice_copy ( mamaPrice  dest,
const mamaPrice  src 
)

Copy a price object.

The destination object must have already been allocated using mamaPrice_create().

Parameters
copyThe destination price.
srcThe price to copy.
MAMAExpDLL mama_status mamaPrice_add ( mamaPrice  dest,
const mamaPrice  rhs 
)

Add to a price object.

The destination object must have already been allocated using mamaPrice_create().

Parameters
destThe price to add to.
rhsThe price to add.
MAMAExpDLL mama_status mamaPrice_subtract ( mamaPrice  dest,
const mamaPrice  rhs 
)

Subtract from a price object.

The destination object must have already been allocated using mamaPrice_create().

Parameters
destThe price to subtract from.
srcThe price to subtract.
MAMAExpDLL int mamaPrice_equal ( const mamaPrice  lhs,
const mamaPrice  rhs 
)

Check for equality between two price objects.

Parameters
lhsThe first price to compare.
rhsThe second price to compare.
MAMAExpDLL double mamaPrice_compare ( const mamaPrice  lhs,
const mamaPrice  rhs 
)

Compare two price objects.

The return value is negative if lhs is earlier than rhs, positive if lhs is greater than rhs and zero if the two are equal.

Parameters
lhsThe first price to compare.
rhsThe second price to compare.
MAMAExpDLL mama_status mamaPrice_setValue ( mamaPrice  price,
double  value 
)

Set the price value only (no hint information).

Parameters
priceThe price to set.
valueThe value to set.
MAMAExpDLL mama_status mamaPrice_setPrecision ( mamaPrice  price,
mamaPricePrecision  precision 
)

Set the price precision.

Parameters
priceThe price to set.
precisionThe precision for the price.
MAMAExpDLL mama_status mamaPrice_setIsValidPrice ( mamaPrice  price,
mama_bool_t  valid 
)

Set if price contains a valid value.

(0 may be a valid value)

Parameters
priceThe price to set.
validIf price contains a valid value.
MAMAExpDLL mama_status mamaPrice_setHints ( mamaPrice  price,
mamaPriceHints  hints 
)

Set all of the price hints.

Parameters
priceThe price to set.
hintsThe hints for the price.
MAMAExpDLL mama_status mamaPrice_setWithHints ( mamaPrice  price,
double  value,
mamaPriceHints  hints 
)

Set the price with hint information.

Parameters
priceThe price to set.
valueThe value to set.
hintsThe price hints.
MAMAExpDLL mama_status mamaPrice_setFromString ( mamaPrice  price,
const char *  str 
)

Set the price from a string representation, preserving any detectable hints.

Parameters
priceThe price to set.
strThe string representation of some price.
MAMAExpDLL mama_status mamaPrice_getValue ( const mamaPrice  price,
double *  value 
)

Get the price value only.

Parameters
priceThe price to get.
valueThe the decimal value of the price.
MAMAExpDLL mama_status mamaPrice_getRoundedValue ( const mamaPrice  price,
const mamaPricePrecision  precision,
double *  value 
)

This function obtains the double value of a price rounded to the supplied precision.

Parameters
[in]priceThe price to round.
[in]precisionThe precision to use for rounding.
[out]valueThe rounded value.
Returns
Indicates whether the function succeeded or failed and could be one of:
  • MAMA_STATUS_INVALID_ARG
  • MAMA_STATUS_OK
MAMAExpDLL mama_status mamaPrice_getPrecision ( const mamaPrice  price,
mamaPricePrecision precision 
)

Get the price precision.

Parameters
priceThe price to get.
precisionThe price precision hint.
MAMAExpDLL mama_status mamaPrice_getIsValidPrice ( const mamaPrice  price,
mama_bool_t valid 
)

Check if price contains a valid value.

Parameters
priceThe price to get.
validIf the value is valid.
MAMAExpDLL mama_status mamaPrice_getHints ( const mamaPrice  price,
mamaPriceHints hints 
)

Get the price hints.

Parameters
priceThe price to get.
hintsThe price hints.
MAMAExpDLL mama_status mamaPrice_getWithHints ( const mamaPrice  price,
double *  value,
mamaPricePrecision precision 
)

Get the price with special, optional hints.

Parameters
priceThe price to get.
valueThe decimal value of the price.
precisionThe precision of the price.
MAMAExpDLL mama_status mamaPrice_getAsString ( const mamaPrice  price,
char *  str,
mama_size_t  maxLen 
)

Get the price as a string, formatted according to the hints provided.

Parameters
priceThe price to set.
strThe string buffer to update.
maxLenThe maximum size of the string buffer (including trailing '\0').
MAMAExpDLL mama_status mamaPrice_negate ( mamaPrice  price)

Negate the price value.

Hints and precisions are not affected.

MAMAExpDLL mama_status mamaPrice_isZero ( const mamaPrice  price,
mama_bool_t result 
)

Return whether the price has a value equivalent to zero.

It may not be exactly 0.0, but we check against +/- epsilon.

MAMAExpDLL mamaPricePrecision mamaPrice_decimals2Precision ( mama_i32_t  places)

Return the appropriate precision code for a given number of decimal places.

MAMAExpDLL mamaPricePrecision mamaPrice_denom2Precision ( mama_i32_t  denominator)

Return the appropriate precision code for a given fractional denominator.

MAMAExpDLL mama_i32_t mamaPrice_precision2Decimals ( mamaPricePrecision  precision)

Return the number of decimal places for a given precision code.

MAMAExpDLL mama_i32_t mamaPrice_precision2Denom ( mamaPricePrecision  precision)

Return the fractional denominator for a given precision code.



© 2012 Linux Foundation