Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
5d9e4b62
Commit
5d9e4b62
authored
Jul 29, 2024
by
Simon Gene Gottlieb
Committed by
Jesse Beder
Nov 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch: split fp_to_string.h into fptostring.h and fptostring.cpp
parent
28c0a1bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
11 deletions
+33
-11
include/yaml-cpp/emitter.h
+1
-1
include/yaml-cpp/fptostring.h
+22
-0
include/yaml-cpp/node/convert.h
+1
-1
src/fptostring.cpp
+8
-8
test/fptostring_test.cpp
+1
-1
No files found.
include/yaml-cpp/emitter.h
View file @
5d9e4b62
...
...
@@ -21,7 +21,7 @@
#include "yaml-cpp/emittermanip.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/ostream_wrapper.h"
#include "yaml-cpp/fp
_to_
string.h"
#include "yaml-cpp/fp
to
string.h"
namespace
YAML
{
class
Binary
;
...
...
include/yaml-cpp/fptostring.h
0 → 100644
View file @
5d9e4b62
// SPDX-FileCopyrightText: 2024 Simon Gene Gottlieb
// SPDX-License-Identifier: MIT
#ifndef YAML_H_FP_TO_STRING
#define YAML_H_FP_TO_STRING
#include "contrib/dragonbox.h"
#include <array>
#include <cassert>
#include <cmath>
#include <sstream>
#include <tuple>
namespace
YAML
{
// "precision = 0" refers to shortest known unique representation of the value
std
::
string
FpToString
(
float
v
,
size_t
precision
=
0
);
std
::
string
FpToString
(
double
v
,
size_t
precision
=
0
);
std
::
string
FpToString
(
long
double
v
,
size_t
precision
=
0
);
}
#endif
include/yaml-cpp/node/convert.h
View file @
5d9e4b62
...
...
@@ -28,7 +28,7 @@
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/null.h"
#include "yaml-cpp/fp
_to_
string.h"
#include "yaml-cpp/fp
to
string.h"
namespace
YAML
{
...
...
include/yaml-cpp/fp_to_string.h
→
src/fptostring.cpp
View file @
5d9e4b62
// SPDX-FileCopyrightText: 2024 Simon Gene Gottlieb
// SPDX-License-Identifier: MIT
#ifndef YAML_H_FP_TO_STRING
#define YAML_H_FP_TO_STRING
#include "contrib/dragonbox.h"
#include <array>
#include <cassert>
#include <cmath>
#include <limits>
#include <sstream>
#include <tuple>
...
...
@@ -32,7 +30,7 @@ namespace fp_formatting {
* assert(buffer[1] == '2');
* assert(buffer[2] == '3');
*/
in
line
in
t
ConvertToChars
(
char
*
begin
,
char
*
end
,
size_t
value
,
int
width
=
1
)
{
int
ConvertToChars
(
char
*
begin
,
char
*
end
,
size_t
value
,
int
width
=
1
)
{
assert
(
width
>=
1
);
assert
(
end
>=
begin
);
// end must be after begin
assert
(
end
-
begin
>=
width
);
// Buffer must be large enough
...
...
@@ -184,24 +182,26 @@ std::string FpToString(T v, int precision = 0) {
}
}
inline
std
::
string
FpToString
(
float
v
,
size_t
precision
=
0
)
{
std
::
string
FpToString
(
float
v
,
size_t
precision
)
{
return
detail
::
fp_formatting
::
FpToString
(
v
,
precision
);
}
inline
std
::
string
FpToString
(
double
v
,
size_t
precision
=
0
)
{
std
::
string
FpToString
(
double
v
,
size_t
precision
)
{
return
detail
::
fp_formatting
::
FpToString
(
v
,
precision
);
}
/**
* dragonbox only works for floats/doubles not long double
*/
inline
std
::
string
FpToString
(
long
double
v
,
size_t
precision
=
std
::
numeric_limits
<
long
double
>::
max_digits10
)
{
std
::
string
FpToString
(
long
double
v
,
size_t
precision
)
{
std
::
stringstream
ss
;
ss
.
imbue
(
std
::
locale
(
"C"
));
if
(
precision
==
0
)
{
precision
=
std
::
numeric_limits
<
long
double
>::
max_digits10
;
}
ss
.
precision
(
precision
);
ss
<<
v
;
return
ss
.
str
();
}
}
#endif
test/fp
_to_
string_test.cpp
→
test/fp
to
string_test.cpp
View file @
5d9e4b62
#include "yaml-cpp/fp
_to_
string.h"
#include "yaml-cpp/fp
to
string.h"
#include "gtest/gtest.h"
namespace
YAML
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment