| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| 8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| 9 | 9 |
| 10 #include <stdint.h> // For intptr_t. | 10 #include <stdint.h> // For intptr_t. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 m_Length = size; | 35 m_Length = size; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Deliberately implicit to avoid calling on every string literal. | 38 // Deliberately implicit to avoid calling on every string literal. |
| 39 CFX_ByteStringC(const FX_CHAR* ptr) { | 39 CFX_ByteStringC(const FX_CHAR* ptr) { |
| 40 m_Ptr = (const uint8_t*)ptr; | 40 m_Ptr = (const uint8_t*)ptr; |
| 41 m_Length = ptr ? FXSYS_strlen(ptr) : 0; | 41 m_Length = ptr ? FXSYS_strlen(ptr) : 0; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Deliberately implicit to avoid calling on every string literal. | 44 // Deliberately implicit to avoid calling on every string literal. |
| 45 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However, | 45 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. |
| 46 // the use of char rvalues are not caught at compile time. They are | |
| 47 // implicitly promoted to CFX_ByteString (see below) and then the | |
| 48 // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate | |
| 49 // constructor below. The CFX_ByteString then typically goes out of scope | |
| 50 // and |m_Ptr| may be left pointing to invalid memory. Beware. | |
| 51 CFX_ByteStringC(FX_CHAR& ch) { | 46 CFX_ByteStringC(FX_CHAR& ch) { |
| 52 m_Ptr = (const uint8_t*)&ch; | 47 m_Ptr = (const uint8_t*)&ch; |
| 53 m_Length = 1; | 48 m_Length = 1; |
| 54 } | 49 } |
| 55 | 50 |
| 56 CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) { | 51 CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) { |
| 57 m_Ptr = (const uint8_t*)ptr; | 52 m_Ptr = (const uint8_t*)ptr; |
| 58 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len; | 53 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len; |
| 59 } | 54 } |
| 60 | 55 |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 m_Length = 0; | 352 m_Length = 0; |
| 358 } | 353 } |
| 359 | 354 |
| 360 // Deliberately implicit to avoid calling on every string literal. | 355 // Deliberately implicit to avoid calling on every string literal. |
| 361 CFX_WideStringC(const FX_WCHAR* ptr) { | 356 CFX_WideStringC(const FX_WCHAR* ptr) { |
| 362 m_Ptr = ptr; | 357 m_Ptr = ptr; |
| 363 m_Length = ptr ? FXSYS_wcslen(ptr) : 0; | 358 m_Length = ptr ? FXSYS_wcslen(ptr) : 0; |
| 364 } | 359 } |
| 365 | 360 |
| 366 // Deliberately implicit to avoid calling on every string literal. | 361 // Deliberately implicit to avoid calling on every string literal. |
| 367 // |ch| must be an lvalue that outlives the the CFX_WideStringC. However, | 362 // |ch| must be an lvalue that outlives the the CFX_WideStringC. |
| 368 // the use of char rvalues are not caught at compile time. They are | |
| 369 // implicitly promoted to CFX_WideString (see below) and then the | |
| 370 // CFX_WideStringC is constructed from the CFX_WideString via the alternate | |
| 371 // constructor below. The CFX_WideString then typically goes out of scope | |
| 372 // and |m_Ptr| may be left pointing to invalid memory. Beware. | |
| 373 CFX_WideStringC(FX_WCHAR& ch) { | 363 CFX_WideStringC(FX_WCHAR& ch) { |
| 374 m_Ptr = &ch; | 364 m_Ptr = &ch; |
| 375 m_Length = 1; | 365 m_Length = 1; |
| 376 } | 366 } |
| 377 | 367 |
| 378 CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) { | 368 CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) { |
| 379 m_Ptr = ptr; | 369 m_Ptr = ptr; |
| 380 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len; | 370 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len; |
| 381 } | 371 } |
| 382 | 372 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 670 } |
| 681 | 671 |
| 682 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 672 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
| 683 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 673 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
| 684 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); | 674 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); |
| 685 } | 675 } |
| 686 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); | 676 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); |
| 687 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 677 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
| 688 | 678 |
| 689 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ | 679 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| OLD | NEW |