Open CASCADE Technology  6.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions
Interface_FloatWriter Class Reference

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

#include <Interface_FloatWriter.hxx>

Public Member Functions

 Interface_FloatWriter (const Standard_Integer chars=0)
 Creates a FloatWriter ready to work, with default options -
More...
 
void SetFormat (const Standard_CString form, const Standard_Boolean reset=Standard_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
More...
 
void SetFormatForRange (const Standard_CString form, const Standard_Real R1, const Standard_Real R2)
 
Sets a secondary Format for Real, to be applied between R1 and <br>
     R2 (in absolute values). A Call to SetRealForm cancels this <br>
     secondary form if <reset> is True. <br>
     (Default from Creation is "%f" between 0.1 and 1000.) <br>

Warning : if the condition (0. <= R1 < R2) is not fulfilled, this
secondary form is canceled.
More...

 
void SetZeroSuppress (const Standard_Boolean mode)
 Sets Sending Real Parameters to suppress trailing Zeros and
Null Exponant ("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)
More...
 
void SetDefaults (const Standard_Integer chars=0)
 Sets again options to the defaults given by Create
More...
 
void Options (Standard_Boolean &zerosup, Standard_Boolean &range, Standard_Real &R1, Standard_Real &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)
More...
 
Standard_CString MainFormat () const
 
 Returns the main format <br>

was C++ : return const
More...

 
Standard_CString FormatForRange () const
 
 Returns the format for range, if set <br>
      Meaningful only if <range> from Options is True <br>

was C++ : return const
More...

 
Standard_Integer Write (const Standard_Real val, const Standard_CString text) const
 
Writes a Real value <val> to a string <text> by using the <br>
     options. Returns the useful Length of produced string. <br>
     It calls the class method Convert. <br>

Warning : <text> is assumed to be wide enough (20-30 is correct)
And, even if declared in, its content will be modified
More...

 

Static Public Member Functions

static Standard_Integer Convert (const Standard_Real val, const Standard_CString text, const Standard_Boolean zerosup, const Standard_Real Range1, const Standard_Real Range2, const Standard_CString mainform, const Standard_CString rangeform)
 
This class method converts a Real Value to a string, given <br>
     options given as arguments. It can be called independantly. <br>

Warning : even if declared in, content of <text> will be modified
More...

 

Detailed Description

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

      - to suppress trailing '0' and 'E+00' (if desired) <br>
      - to control exponant output and floating point output <br>


Formats are given in the form used by printf-sprintf

Constructor & Destructor Documentation

Interface_FloatWriter::Interface_FloatWriter ( const Standard_Integer  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

static Standard_Integer Interface_FloatWriter::Convert ( const Standard_Real  val,
const Standard_CString  text,
const Standard_Boolean  zerosup,
const Standard_Real  Range1,
const Standard_Real  Range2,
const Standard_CString  mainform,
const Standard_CString  rangeform 
)
static

This class method converts a Real Value to a string, given <br>
     options given as arguments. It can be called independantly. <br>

Warning : even if declared in, content of <text> will be modified

Standard_CString Interface_FloatWriter::FormatForRange ( ) const

 Returns the format for range, if set <br>
      Meaningful only if <range> from Options is True <br>

was C++ : return const

Standard_CString Interface_FloatWriter::MainFormat ( ) const

 Returns the main format <br>

was C++ : return const

void Interface_FloatWriter::Options ( Standard_Boolean zerosup,
Standard_Boolean range,
Standard_Real R1,
Standard_Real 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)

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

Sets again options to the defaults given by Create

void Interface_FloatWriter::SetFormat ( const Standard_CString  form,
const Standard_Boolean  reset = Standard_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 Interface_FloatWriter::SetFormatForRange ( const Standard_CString  form,
const Standard_Real  R1,
const Standard_Real  R2 
)

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

Warning : if the condition (0. <= R1 < R2) is not fulfilled, this
secondary form is canceled.

void Interface_FloatWriter::SetZeroSuppress ( const Standard_Boolean  mode)

Sets Sending Real Parameters to suppress trailing Zeros and
Null Exponant ("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)

Standard_Integer Interface_FloatWriter::Write ( const Standard_Real  val,
const Standard_CString  text 
) const

Writes a Real value <val> to a string <text> by using the <br>
     options. Returns the useful Length of produced string. <br>
     It calls the class method Convert. <br>

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: