LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
LimaCommon.cpp
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#include "common/LimaCommon.h"
7
8#ifdef WIN32
9
10#ifdef LIMA_COMMON_EXPORTING
11#define LIMA_COMMON_EXPORT __declspec(dllexport)
12#else
13#define LIMA_COMMON_EXPORT __declspec(dllimport)
14#endif
15
16
17#else // Not WIN32
18
19#define LIMA_COMMON_EXPORT
20
21#endif
22
23
24namespace Lima
25{
26namespace Common
27{
28
30
31}
32
33#ifndef USE_STD_BITSET_FOR_LINGUISTIC_CODE
34LIMA_COMMON_EXPORT QDebug& operator<<(QDebug& os, const uint128_t value)
35{
36 std::stringstream ss;
37 ss << value;
38 return os << ss.str();
39}
40
41LIMA_COMMON_EXPORT QTextStream& operator<<(QTextStream& os, const uint128_t value)
42{
43 std::stringstream ss;
44 ss << value;
45 return os << ss.str().c_str();
46}
47
48LIMA_COMMON_EXPORT std::ostream& operator<<(std::ostream& os, const uint128_t value)
49{
50 std::ostream::sentry s(os);
51 if (s)
52 {
53 char buffer[128];
54 char* d = std::end(buffer);
55 uint128_t t = value;
56 do
57 {
58 -- d;
59 *d = "0123456789"[t % 10];
60 t /= 10;
61 } while (t != 0);
62
63 int len = std::end(buffer) - d;
64 if (os.rdbuf()->sputn(d, len) != len)
65 {
66 os.setstate(std::ios_base::badbit);
67 }
68 }
69 return os;
70}
71
72LIMA_COMMON_EXPORT std::istream& operator>>(std::istream& is, uint128_t& value)
73{
74 value = 0;
75 char c = 0;
76
77 while (is.get(c))
78 {
79 if (!std::isspace(c))
80 {
81 is.unget();
82 break;
83 }
84 }
85 while (is.get(c))
86 {
87 if (!std::isdigit(c))
88 {
89 is.unget();
90 break;
91 }
92 value *= 10;
93 value += c - '0';
94 }
95
96 return is;
97}
98#endif
99
100}
#define LIMA_COMMON_EXPORT
LIMA_COMMON_EXPORT void fakeSymbolForWindowsLinking()
NAUTITIA.
std::ostream & operator<<(ostream &os, const Node &node)
LIMA_COMMON_EXPORT std::istream & operator>>(std::istream &is, uint128_t &value)