|
||||
File indexing completed on 2025-01-18 10:04:07
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 0028 //! This class converts a floating number (Real) to a string 0029 //! It can be used if the standard C-C++ output functions 0030 //! (sprintf or std::cout<<) are not convenient. That is to say : 0031 //! - to suppress trailing '0' and 'E+00' (if desired) 0032 //! - to control exponent output and floating point output 0033 //! 0034 //! Formats are given in the form used by printf-sprintf 0035 class Interface_FloatWriter 0036 { 0037 public: 0038 0039 DEFINE_STANDARD_ALLOC 0040 0041 0042 //! Creates a FloatWriter ready to work, with default options - 0043 //! - zero suppress option is set 0044 //! - main format is set to "%E" 0045 //! - secondary format is set to "%f" for values between 0.1 and 0046 //! 1000. in absolute values 0047 //! If <chars> is given (and positive), it will produce options 0048 //! to produce this count of characters : "%<chars>f","%<chars>%E" 0049 Standard_EXPORT Interface_FloatWriter(const Standard_Integer chars = 0); 0050 0051 //! Sets a specific Format for Sending Reals (main format) 0052 //! (Default from Creation is "%E") 0053 //! If <reset> is given True (default), this call clears effects 0054 //! of former calls to SetFormatForRange and SetZeroSuppress 0055 Standard_EXPORT void SetFormat (const Standard_CString form, const Standard_Boolean reset = Standard_True); 0056 0057 //! Sets a secondary Format for Real, to be applied between R1 and 0058 //! R2 (in absolute values). A Call to SetRealForm cancels this 0059 //! secondary form if <reset> is True. 0060 //! (Default from Creation is "%f" between 0.1 and 1000.) 0061 //! Warning : if the condition (0. <= R1 < R2) is not fulfilled, this 0062 //! secondary form is canceled. 0063 Standard_EXPORT void SetFormatForRange (const Standard_CString form, const Standard_Real R1, const Standard_Real R2); 0064 0065 //! Sets Sending Real Parameters to suppress trailing Zeros and 0066 //! Null Exponent ("E+00"), if <mode> is given True, Resets this 0067 //! mode if <mode> is False (in addition to Real Forms) 0068 //! A call to SetRealFrom resets this mode to False ig <reset> is 0069 //! given True (Default from Creation is True) 0070 Standard_EXPORT void SetZeroSuppress (const Standard_Boolean mode); 0071 0072 //! Sets again options to the defaults given by Create 0073 Standard_EXPORT void SetDefaults (const Standard_Integer chars = 0); 0074 0075 //! Returns active options : <zerosup> is the option ZeroSuppress, 0076 //! <range> is True if a range is set, False else 0077 //! R1,R2 give the range (if it is set) 0078 Standard_EXPORT void Options (Standard_Boolean& zerosup, Standard_Boolean& range, Standard_Real& R1, Standard_Real& R2) const; 0079 0080 //! Returns the main format 0081 //! was C++ : return const 0082 Standard_EXPORT Standard_CString MainFormat() const; 0083 0084 //! Returns the format for range, if set 0085 //! Meaningful only if <range> from Options is True 0086 //! was C++ : return const 0087 Standard_EXPORT Standard_CString FormatForRange() const; 0088 0089 //! Writes a Real value <val> to a string <text> by using the 0090 //! options. Returns the useful Length of produced string. 0091 //! It calls the class method Convert. 0092 //! Warning : <text> is assumed to be wide enough (20-30 is correct) 0093 //! And, even if declared in, its content will be modified 0094 Standard_EXPORT Standard_Integer Write (const Standard_Real val, const Standard_CString text) const; 0095 0096 //! This class method converts a Real Value to a string, given 0097 //! options given as arguments. It can be called independently. 0098 //! Warning : even if declared in, content of <text> will be modified 0099 Standard_EXPORT 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); 0100 0101 0102 0103 0104 protected: 0105 0106 0107 0108 0109 0110 private: 0111 0112 0113 0114 Standard_Character themainform[12]; 0115 Standard_Real therange1; 0116 Standard_Real therange2; 0117 Standard_Character therangeform[12]; 0118 Standard_Boolean thezerosup; 0119 0120 0121 }; 0122 0123 0124 0125 0126 0127 0128 0129 #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 |