|
|
|||
File indexing completed on 2026-09-12 09:17:47
0001 // Created on: 1994-04-15 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1994-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Interface_FloatWriter_HeaderFile 0018 #define _Interface_FloatWriter_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Real.hxx> 0025 #include <Standard_Boolean.hxx> 0026 0027 //! This class converts a floating number (Real) to a string 0028 //! It can be used if the standard C-C++ output functions 0029 //! (Sprintf or std::cout<<) are not convenient. That is to say : 0030 //! - to suppress trailing '0' and 'E+00' (if desired) 0031 //! - to control exponent output and floating point output 0032 //! 0033 //! Formats are given in the form used by printf-Sprintf 0034 class Interface_FloatWriter 0035 { 0036 public: 0037 DEFINE_STANDARD_ALLOC 0038 0039 //! Creates a FloatWriter ready to work, with default options 0040 //! - zero suppress option is set 0041 //! - main format is set to "%E" 0042 //! - secondary format is set to "%f" for values between 0.1 and 0043 //! 1000. in absolute values 0044 //! If <chars> is given (and positive), it will produce options 0045 //! to produce this count of characters : "%<chars>f","%<chars>%E" 0046 Standard_EXPORT Interface_FloatWriter(const int chars = 0); 0047 0048 //! Sets a specific Format for Sending Reals (main format) 0049 //! (Default from Creation is "%E") 0050 //! If <reset> is given True (default), this call clears effects 0051 //! of former calls to SetFormatForRange and SetZeroSuppress 0052 Standard_EXPORT void SetFormat(const char* const form, const bool reset = true); 0053 0054 //! Sets a secondary Format for Real, to be applied between R1 and 0055 //! R2 (in absolute values). A Call to SetRealForm cancels this 0056 //! secondary form if <reset> is True. 0057 //! (Default from Creation is "%f" between 0.1 and 1000.) 0058 //! Warning : if the condition (0. <= R1 < R2) is not fulfilled, this 0059 //! secondary form is canceled. 0060 Standard_EXPORT void SetFormatForRange(const char* const form, const double R1, const double R2); 0061 0062 //! Sets Sending Real Parameters to suppress trailing Zeros and 0063 //! Null Exponent ("E+00"), if <mode> is given True, Resets this 0064 //! mode if <mode> is False (in addition to Real Forms) 0065 //! A call to SetRealFrom resets this mode to False ig <reset> is 0066 //! given True (Default from Creation is True) 0067 Standard_EXPORT void SetZeroSuppress(const bool mode); 0068 0069 //! Sets again options to the defaults given by Create 0070 Standard_EXPORT void SetDefaults(const int chars = 0); 0071 0072 //! Returns active options : <zerosup> is the option ZeroSuppress, 0073 //! <range> is True if a range is set, False else 0074 //! R1,R2 give the range (if it is set) 0075 Standard_EXPORT void Options(bool& zerosup, bool& range, double& R1, double& R2) const; 0076 0077 //! Returns the main format 0078 //! was C++ : return const 0079 Standard_EXPORT const char* MainFormat() const; 0080 0081 //! Returns the format for range, if set 0082 //! Meaningful only if <range> from Options is True 0083 //! was C++ : return const 0084 Standard_EXPORT const char* FormatForRange() const; 0085 0086 //! Writes a Real value <val> to a string <text> by using the 0087 //! options. Returns the useful Length of produced string. 0088 //! It calls the class method Convert. 0089 //! Warning : <text> is assumed to be wide enough (20-30 is correct) 0090 //! And, even if declared in, its content will be modified 0091 Standard_EXPORT int Write(const double val, const char* const text) const; 0092 0093 //! This class method converts a Real Value to a string, given 0094 //! options given as arguments. It can be called independently. 0095 //! Warning : even if declared in, content of <text> will be modified 0096 Standard_EXPORT static int Convert(const double val, 0097 const char* const text, 0098 const bool zerosup, 0099 const double Range1, 0100 const double Range2, 0101 const char* const mainform, 0102 const char* const rangeform); 0103 0104 private: 0105 char themainform[12]; 0106 double therange1; 0107 double therange2; 0108 char therangeform[12]; 0109 bool thezerosup; 0110 }; 0111 0112 #endif // _Interface_FloatWriter_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|