Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/cpdf_number.cpp

Issue 1776913007: Split fpdf_parser_objects.cpp into per-class .cpp/.h files. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698