VTK  9.2.5
vtkNumberToString.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkNumberToString.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
35#ifndef vtkNumberToString_h
36#define vtkNumberToString_h
37
38#include "vtkIOCoreModule.h" // For export macro
39#include "vtkTypeTraits.h"
40
41#include <ostream>
42#include <string>
43
44class VTKIOCORE_EXPORT vtkNumberToString
45{
46public:
47 struct TagDouble
48 {
49 double Value;
50 TagDouble(const double& value)
51 : Value(value)
52 {
53 }
54 };
55
56 struct TagFloat
57 {
58 float Value;
59 TagFloat(const float& value)
60 : Value(value)
61 {
62 }
63 };
64
65 template <typename T>
66 const T& operator()(const T& val) const
67 {
68 return val;
69 }
70 const TagDouble operator()(const double& val) const { return TagDouble(val); }
71 const TagFloat operator()(const float& val) const { return TagFloat(val); }
72};
73
74VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagDouble& tag);
75VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagFloat& tag);
76
77#endif
78// VTK-HeaderTest-Exclude: vtkNumberToString.h
Convert floating and fixed point numbers to strings.
const T & operator()(const T &val) const
const TagDouble operator()(const double &val) const
const TagFloat operator()(const float &val) const
TagDouble(const double &value)
TagFloat(const float &value)
VTKIOCORE_EXPORT ostream & operator<<(ostream &stream, const vtkNumberToString::TagDouble &tag)