aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/openssl/big_integer/big_integer.h
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2023-08-15 21:09:36 +0300
committeralexvru <alexvru@ydb.tech>2023-08-15 21:42:49 +0300
commitd6f67906ea5b369b47bce8e0a7125d66114fdbde (patch)
treec9c44a3a1a396a6cab33e1260c67f2e5b8b76ea4 /library/cpp/openssl/big_integer/big_integer.h
parentf096c967c8a4b645763f901c889ca0335a0e5412 (diff)
downloadydb-d6f67906ea5b369b47bce8e0a7125d66114fdbde.tar.gz
Support BS autoconfig KIKIMR-19031
Diffstat (limited to 'library/cpp/openssl/big_integer/big_integer.h')
-rw-r--r--library/cpp/openssl/big_integer/big_integer.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/library/cpp/openssl/big_integer/big_integer.h b/library/cpp/openssl/big_integer/big_integer.h
new file mode 100644
index 0000000000..07763c5e13
--- /dev/null
+++ b/library/cpp/openssl/big_integer/big_integer.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <util/generic/ptr.h>
+#include <util/generic/strbuf.h>
+#include <util/generic/utility.h>
+#include <util/generic/string.h>
+
+struct bignum_st;
+
+namespace NOpenSsl {
+ class TBigInteger {
+ inline TBigInteger(bignum_st* impl) noexcept
+ : Impl_(impl)
+ {
+ }
+
+ static int Compare(const TBigInteger& a, const TBigInteger& b) noexcept;
+
+ public:
+ inline TBigInteger(TBigInteger&& other) noexcept {
+ Swap(other);
+ }
+
+ ~TBigInteger() noexcept;
+
+ static TBigInteger FromULong(ui64 value);
+ static TBigInteger FromRegion(const void* ptr, size_t len);
+
+ inline const bignum_st* Impl() const noexcept {
+ return Impl_;
+ }
+
+ inline bignum_st* Impl() noexcept {
+ return Impl_;
+ }
+
+ inline void Swap(TBigInteger& other) noexcept {
+ DoSwap(Impl_, other.Impl_);
+ }
+
+ inline friend bool operator==(const TBigInteger& a, const TBigInteger& b) noexcept {
+ return Compare(a, b) == 0;
+ }
+
+ inline friend bool operator!=(const TBigInteger& a, const TBigInteger& b) noexcept {
+ return !(a == b);
+ }
+
+ size_t NumBytes() const noexcept;
+ size_t ToRegion(void* to) const noexcept;
+
+ TString ToDecimalString() const;
+
+ private:
+ bignum_st* Impl_ = nullptr;
+ };
+}