VTK  9.1.0
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=========================================================================*/
32#ifndef vtkNumberToString_h
33#define vtkNumberToString_h
34
35#include "vtkIOCoreModule.h" // For export macro
36#include "vtkTypeTraits.h"
37
38#include <ostream>
39#include <string>
40
41class VTKIOCORE_EXPORT vtkNumberToString
42{
43public:
44 struct TagDouble
45 {
46 double Value;
47 TagDouble(const double& value)
48 : Value(value)
49 {
50 }
51 };
52
53 struct TagFloat
54 {
55 float Value;
56 TagFloat(const float& value)
57 : Value(value)
58 {
59 }
60 };
61
62 template <typename T>
63 const T& operator()(const T& val) const
64 {
65 return val;
66 }
67 const TagDouble operator()(const double& val) const { return TagDouble(val); }
68 const TagFloat operator()(const float& val) const { return TagFloat(val); }
69};
70
71VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagDouble& tag);
72VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagFloat& tag);
73
74#endif
75// 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
@ value
Definition: vtkX3D.h:226
TagDouble(const double &value)
TagFloat(const float &value)
VTKIOCORE_EXPORT ostream & operator<<(ostream &stream, const vtkNumberToString::TagDouble &tag)