VTK
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 
41 class VTKIOCORE_EXPORT vtkNumberToString
42 {
43 public:
44  struct TagDouble
45  {
46  double Value;
47  TagDouble(const double& value) : Value(value) {}
48  };
49 
50  struct TagFloat
51  {
52  float Value;
53  TagFloat(const float& value) : Value(value) {}
54  };
55 
56  template <typename T>
57  const T& operator()(const T& val) const
58  {
59  return val;
60  }
61  const TagDouble operator()(const double& val) const { return TagDouble(val); }
62  const TagFloat operator()(const float& val) const { return TagFloat(val); }
63 };
64 
65 VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagDouble& tag);
66 VTKIOCORE_EXPORT ostream& operator<<(ostream& stream, const vtkNumberToString::TagFloat& tag);
67 
68 #endif
69 // VTK-HeaderTest-Exclude: vtkNumberToString.h
VTKIOCORE_EXPORT ostream & operator<<(ostream &stream, const vtkNumberToString::TagDouble &tag)
const TagFloat operator()(const float &val) const
TagDouble(const double &value)
const T & operator()(const T &val) const
TagFloat(const float &value)
Convert floating and fixed point numbers to strings.
const TagDouble operator()(const double &val) const