LibreOffice Module sc (master)
1
sc
source
core
opencl
utils.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
4
*
5
* This Source Code Form is subject to the terms of the Mozilla Public
6
* License, v. 2.0. If a copy of the MPL was not distributed with this
7
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
*/
9
10
#pragma once
11
12
#include <sstream>
13
14
namespace
sc::opencl
15
{
16
// The way ostream handles floating point output is pretty broken for our usecase.
17
// The default precision (6) is low, leading to possible precision loss of constant
18
// float arguments in the generated code. Moreover numbers without a fractional
19
// part will be printed as e.g. '2', making them integers in the generated code
20
// (causing problems e.g. with floor() overloads being ambiguous). The std::showpoint
21
// manipulator forces a decimal point, but then all numbers will be printed
22
// at the maximum precision even with insignificant trailing 0's, making the numbers
23
// a pain to read.
24
// And these flags need to be set on every std::stringstream instance we use,
25
// which may be easy to omit.
26
// So as a solution to this:
27
// - provide our own wrapper class
28
// - prohibit direct usage of std::stringstream
29
30
class
outputstream
:
public
std::stringstream
31
{
32
private
:
33
typedef
std::stringstream
base
;
34
35
public
:
36
outputstream
();
37
};
38
39
// Returns a string containing the string representation of the given floating pointer number.
40
// Unlike printf/iostream, this tries to be as precise and representative as possible
41
// (it always includes a decimal point, and it uses the highest precision necessary/possible).
42
std::string
preciseFloat
(
double
f);
43
std::string
preciseFloat
(
long
double
f) =
delete
;
// we do not use these
44
45
#define stringstream do_not_use_std_stringstream
46
}
// namespace
47
48
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sc::opencl::outputstream
Definition:
utils.hxx:31
sc::opencl::outputstream::outputstream
outputstream()
Definition:
utils.cxx:42
sc::opencl::outputstream::base
std::stringstream base
Definition:
utils.hxx:33
sc::opencl
Definition:
formulagroupcl.hxx:14
sc::opencl::preciseFloat
std::string preciseFloat(double f)
Definition:
utils.cxx:55
stringstream
#define stringstream
Definition:
utils.hxx:45
Generated on Sun Jul 30 2023 04:28:14 for LibreOffice Module sc (master) by
1.9.3