OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "core/include/fpdfapi/cpdf_number.h" |
| 8 |
| 9 CPDF_Number::CPDF_Number(const CFX_ByteStringC& str) { |
| 10 FX_atonum(str, m_bInteger, &m_Integer); |
| 11 } |
| 12 |
| 13 CPDF_Number::~CPDF_Number() {} |
| 14 |
| 15 CPDF_Object::Type CPDF_Number::GetType() const { |
| 16 return NUMBER; |
| 17 } |
| 18 |
| 19 CPDF_Object* CPDF_Number::Clone(FX_BOOL bDirect) const { |
| 20 return m_bInteger ? new CPDF_Number(m_Integer) : new CPDF_Number(m_Float); |
| 21 } |
| 22 |
| 23 FX_FLOAT CPDF_Number::GetNumber() const { |
| 24 return m_bInteger ? static_cast<FX_FLOAT>(m_Integer) : m_Float; |
| 25 } |
| 26 |
| 27 int CPDF_Number::GetInteger() const { |
| 28 return m_bInteger ? m_Integer : static_cast<int>(m_Float); |
| 29 } |
| 30 |
| 31 bool CPDF_Number::IsNumber() const { |
| 32 return true; |
| 33 } |
| 34 |
| 35 CPDF_Number* CPDF_Number::AsNumber() { |
| 36 return this; |
| 37 } |
| 38 |
| 39 const CPDF_Number* CPDF_Number::AsNumber() const { |
| 40 return this; |
| 41 } |
| 42 |
| 43 void CPDF_Number::SetString(const CFX_ByteString& str) { |
| 44 FX_atonum(str, m_bInteger, &m_Integer); |
| 45 } |
| 46 |
| 47 CFX_ByteString CPDF_Number::GetString() const { |
| 48 return m_bInteger ? CFX_ByteString::FormatInteger(m_Integer, FXFORMAT_SIGNED) |
| 49 : CFX_ByteString::FormatFloat(m_Float); |
| 50 } |
OLD | NEW |