1 // Copyright 2018 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXCRT_FX_NUMBER_H_ 8 #define CORE_FXCRT_FX_NUMBER_H_ 9 10 #include <stdint.h> 11 12 #include "core/fxcrt/bytestring.h" 13 #include "third_party/abseil-cpp/absl/types/variant.h" 14 15 class FX_Number { 16 public: 17 FX_Number(); 18 explicit FX_Number(uint32_t value) = delete; // catch misuse. 19 explicit FX_Number(int32_t value); 20 explicit FX_Number(float value); 21 explicit FX_Number(ByteStringView str); 22 23 bool IsInteger() const; 24 bool IsSigned() const; 25 26 int32_t GetSigned() const; // Underflow/Overflow possible. 27 float GetFloat() const; 28 29 private: 30 absl::variant<uint32_t, int32_t, float> value_ = 0u; 31 }; 32 33 #endif // CORE_FXCRT_FX_NUMBER_H_ 34