Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
Interface_FloatWriter Class Reference

This class converts a floating number (Real) to a string It can be used if the standard C-C++ output functions (Sprintf or std::cout<<) are not convenient. That is to say : More...

#include <Interface_FloatWriter.hxx>

Public Member Functions

 Interface_FloatWriter (const int chars=0)
 Creates a FloatWriter ready to work, with default options.
 
void SetFormat (const char *const form, const bool reset=true)
 Sets a specific Format for Sending Reals (main format) (Default from Creation is "%E") If <reset> is given True (default), this call clears effects of former calls to SetFormatForRange and SetZeroSuppress.
 
void SetFormatForRange (const char *const form, const double R1, const double R2)
 Sets a secondary Format for Real, to be applied between R1 and R2 (in absolute values). A Call to SetRealForm cancels this secondary form if <reset> is True. (Default from Creation is "%f" between 0.1 and 1000.) Warning : if the condition (0. <= R1 < R2) is not fulfilled, this secondary form is canceled.
 
void SetZeroSuppress (const bool mode)
 Sets Sending Real Parameters to suppress trailing Zeros and Null Exponent ("E+00"), if <mode> is given True, Resets this mode if <mode> is False (in addition to Real Forms) A call to SetRealFrom resets this mode to False ig <reset> is given True (Default from Creation is True)
 
void SetDefaults (const int chars=0)
 Sets again options to the defaults given by Create.
 
void Options (bool &zerosup, bool &range, double &R1, double &R2) const
 Returns active options : <zerosup> is the option ZeroSuppress, <range> is True if a range is set, False else R1,R2 give the range (if it is set)
 
const charMainFormat () const
 Returns the main format was C++ : return const.
 
const charFormatForRange () const
 Returns the format for range, if set Meaningful only if <range> from Options is True was C++ : return const.
 
int Write (const double val, const char *const text) const
 Writes a Real value <val> to a string <text> by using the options. Returns the useful Length of produced string. It calls the class method Convert. Warning : <text> is assumed to be wide enough (20-30 is correct) And, even if declared in, its content will be modified.
 

Static Public Member Functions

static int Convert (const double val, const char *const text, const bool zerosup, const double Range1, const double Range2, const char *const mainform, const char *const rangeform)
 This class method converts a Real Value to a string, given options given as arguments. It can be called independently. Warning : even if declared in, content of <text> will be modified.
 

Detailed Description

This class converts a floating number (Real) to a string It can be used if the standard C-C++ output functions (Sprintf or std::cout<<) are not convenient. That is to say :

Formats are given in the form used by printf-Sprintf

Constructor & Destructor Documentation

◆ Interface_FloatWriter()

Interface_FloatWriter::Interface_FloatWriter ( const int chars = 0)

Creates a FloatWriter ready to work, with default options.

  • zero suppress option is set
  • main format is set to "%E"
  • secondary format is set to "%f" for values between 0.1 and
  1. in absolute values If <chars> is given (and positive), it will produce options to produce this count of characters : "%<chars>f","%<chars>%E"

Member Function Documentation

◆ Convert()

static int Interface_FloatWriter::Convert ( const double val,
const char *const text,
const bool zerosup,
const double Range1,
const double Range2,
const char *const mainform,
const char *const rangeform )
static

This class method converts a Real Value to a string, given options given as arguments. It can be called independently. Warning : even if declared in, content of <text> will be modified.

◆ FormatForRange()

const char * Interface_FloatWriter::FormatForRange ( ) const

Returns the format for range, if set Meaningful only if <range> from Options is True was C++ : return const.

◆ MainFormat()

const char * Interface_FloatWriter::MainFormat ( ) const

Returns the main format was C++ : return const.

◆ Options()

void Interface_FloatWriter::Options ( bool & zerosup,
bool & range,
double & R1,
double & R2 ) const

Returns active options : <zerosup> is the option ZeroSuppress, <range> is True if a range is set, False else R1,R2 give the range (if it is set)

◆ SetDefaults()

void Interface_FloatWriter::SetDefaults ( const int chars = 0)

Sets again options to the defaults given by Create.

◆ SetFormat()

void Interface_FloatWriter::SetFormat ( const char *const form,
const bool reset = true )

Sets a specific Format for Sending Reals (main format) (Default from Creation is "%E") If <reset> is given True (default), this call clears effects of former calls to SetFormatForRange and SetZeroSuppress.

◆ SetFormatForRange()

void Interface_FloatWriter::SetFormatForRange ( const char *const form,
const double R1,
const double R2 )

Sets a secondary Format for Real, to be applied between R1 and R2 (in absolute values). A Call to SetRealForm cancels this secondary form if <reset> is True. (Default from Creation is "%f" between 0.1 and 1000.) Warning : if the condition (0. <= R1 < R2) is not fulfilled, this secondary form is canceled.

◆ SetZeroSuppress()

void Interface_FloatWriter::SetZeroSuppress ( const bool mode)

Sets Sending Real Parameters to suppress trailing Zeros and Null Exponent ("E+00"), if <mode> is given True, Resets this mode if <mode> is False (in addition to Real Forms) A call to SetRealFrom resets this mode to False ig <reset> is given True (Default from Creation is True)

◆ Write()

int Interface_FloatWriter::Write ( const double val,
const char *const text ) const

Writes a Real value <val> to a string <text> by using the options. Returns the useful Length of produced string. It calls the class method Convert. Warning : <text> is assumed to be wide enough (20-30 is correct) And, even if declared in, its content will be modified.


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