FormattedDouble.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GNSSTK_FORMATTEDDOUBLE_HPP
40 #define GNSSTK_FORMATTEDDOUBLE_HPP
41 
42 #include <iostream>
43 #include "StringUtils.hpp"
44 
45 namespace gnsstk
46 {
71  {
72  public:
96  FormattedDouble(double d,
98  unsigned mantissa = 0, unsigned exponent = 2,
99  unsigned width = 0, char expChar = 'e',
102 
116  explicit FormattedDouble(unsigned width = 0, char expChar = 'e');
117 
133  explicit FormattedDouble(const std::string& str, unsigned width = 0,
134  char expChar = 'e');
135 
137  operator double() const
138  { return val; }
139 
141  operator double&()
142  { return val; }
143 
145  inline operator std::string();
146 
149  inline FormattedDouble operator/(double d) const;
150 
153  inline FormattedDouble operator*(double d) const;
154 
157  { val++; return *this; }
160  { val++; return *this; }
163  { val--; return *this; }
166  { val--; return *this; }
167 
169  FormattedDouble& operator=(const FormattedDouble& right) = default;
170 
173  { val = d; return *this; }
174 
176  FormattedDouble& operator=(const std::string& s);
177 
179  void dump(std::ostream& s) const;
180 
181  double val;
183  unsigned mantissaLen;
184  unsigned exponentLen;
185  unsigned totalLen;
189  }; // class FormattedDouble
190 
191 
193  std::ostream& operator<<(std::ostream& s, const FormattedDouble& d);
205  std::istream& operator>>(std::istream& s, FormattedDouble& d);
206 
207 
208  FormattedDouble :: operator std::string()
209  {
210  std::ostringstream s;
211  s << *this;
212  return s.str();
213  }
214 
216  {
217  FormattedDouble rv(*this);
218  rv.val /= d;
219  return rv;
220  }
221 
223  {
224  FormattedDouble rv(*this);
225  rv.val *= d;
226  return rv;
227  }
228 
229 } // namespace gnsstk
230 
231 #endif // FORMATTEDDOUBLE_HPP
gnsstk::FormattedDouble::operator=
FormattedDouble & operator=(const FormattedDouble &right)=default
Copy assignment.
gnsstk::FormattedDouble::operator=
FormattedDouble & operator=(double d)
Assign a value without affecting formatting.
Definition: FormattedDouble.hpp:172
gnsstk::FormattedDouble::exponentLen
unsigned exponentLen
How many digits of exponent.
Definition: FormattedDouble.hpp:184
gnsstk::StringUtils::FFAlign::Left
@ Left
Formatted output will be left-aligned.
StringUtils.hpp
gnsstk::operator>>
std::istream & operator>>(FFStream &i, FFData &f)
Definition: FFData.cpp:65
gnsstk::FormattedDouble::exponentChar
char exponentChar
What character delimits the exponent.
Definition: FormattedDouble.hpp:186
gnsstk::FormattedDouble::operator/
FormattedDouble operator/(double d) const
Definition: FormattedDouble.hpp:215
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::FormattedDouble::operator*
FormattedDouble operator*(double d) const
Definition: FormattedDouble.hpp:222
gnsstk::StringUtils::FFLead
FFLead
Leading character for floatFormat(), after any whitespace or sign.
Definition: StringUtils.hpp:109
gnsstk::FormattedDouble::operator--
FormattedDouble & operator--()
Decrement the value (prefix).
Definition: FormattedDouble.hpp:162
gnsstk::FormattedDouble
Definition: FormattedDouble.hpp:70
gnsstk::StringUtils::FFSign::NegOnly
@ NegOnly
Prefix output with a minus sign (neg) or nothing (pos)
gnsstk::FormattedDouble::alignment
StringUtils::FFAlign alignment
Alignment when padding with space.
Definition: FormattedDouble.hpp:188
gnsstk::FormattedDouble::dump
void dump(std::ostream &s) const
debug output all data members
Definition: FormattedDouble.cpp:143
gnsstk::FormattedDouble::leadSign
StringUtils::FFSign leadSign
How to handle signs for positive val.
Definition: FormattedDouble.hpp:187
gnsstk::FormattedDouble::operator--
FormattedDouble operator--(int)
Decrement the value (postfix).
Definition: FormattedDouble.hpp:165
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
gnsstk::FormattedDouble::operator++
FormattedDouble & operator++()
Increment the value (prefix).
Definition: FormattedDouble.hpp:156
gnsstk::FormattedDouble::FormattedDouble
FormattedDouble(double d, StringUtils::FFLead lead, unsigned mantissa=0, unsigned exponent=2, unsigned width=0, char expChar='e', StringUtils::FFSign sign=StringUtils::FFSign::NegOnly, StringUtils::FFAlign align=StringUtils::FFAlign::Left)
Definition: FormattedDouble.cpp:44
gnsstk::FormattedDouble::mantissaLen
unsigned mantissaLen
How many digits of mantissa.
Definition: FormattedDouble.hpp:183
gnsstk::FormattedDouble::totalLen
unsigned totalLen
Total width of space-padded value.
Definition: FormattedDouble.hpp:185
gnsstk::FormattedDouble::leadChar
StringUtils::FFLead leadChar
Leading non-space character.
Definition: FormattedDouble.hpp:182
gnsstk::StringUtils::FFSign
FFSign
How to handle sign in floatFormat()
Definition: StringUtils.hpp:117
gnsstk::FormattedDouble::operator++
FormattedDouble operator++(int)
Increment the value (postfix).
Definition: FormattedDouble.hpp:159
gnsstk::StringUtils::FFAlign
FFAlign
Alignment of data for floatFormat()
Definition: StringUtils.hpp:125
gnsstk::FormattedDouble::val
double val
The value as read or to be formatted.
Definition: FormattedDouble.hpp:181


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39