1 // Copyright 2018 PDFium Authors. All rights reserved. 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 14 class FX_Number { 15 public: 16 FX_Number(); 17 explicit FX_Number(uint32_t value) = delete; 18 explicit FX_Number(int32_t value); 19 explicit FX_Number(float value); 20 explicit FX_Number(ByteStringView str); 21 IsInteger()22 bool IsInteger() const { return m_bInteger; } IsSigned()23 bool IsSigned() const { return m_bSigned; } 24 25 int32_t GetSigned() const; // Underflow/Overflow possible. 26 float GetFloat() const; 27 28 private: 29 bool m_bInteger; // One of the two integers vs. float type. 30 bool m_bSigned; // Only valid if |m_bInteger|. 31 union { 32 uint32_t m_UnsignedValue; 33 int32_t m_SignedValue; 34 float m_FloatValue; 35 }; 36 }; 37 38 #endif // CORE_FXCRT_FX_NUMBER_H_ 39