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 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 m_pData.Reset(StringData::Create(pStr, nLen)); | 87 m_pData.Reset(StringData::Create(pStr, nLen)); |
88 } | 88 } |
89 | 89 |
90 CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) { | 90 CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) { |
91 if (nLen > 0) { | 91 if (nLen > 0) { |
92 m_pData.Reset( | 92 m_pData.Reset( |
93 StringData::Create(reinterpret_cast<const FX_CHAR*>(pStr), nLen)); | 93 StringData::Create(reinterpret_cast<const FX_CHAR*>(pStr), nLen)); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
| 97 CFX_ByteString::CFX_ByteString() {} |
| 98 |
| 99 CFX_ByteString::CFX_ByteString(const CFX_ByteString& other) |
| 100 : m_pData(other.m_pData) {} |
| 101 |
| 102 CFX_ByteString::CFX_ByteString(CFX_ByteString&& other) { |
| 103 m_pData.Swap(other.m_pData); |
| 104 } |
| 105 |
97 CFX_ByteString::CFX_ByteString(char ch) { | 106 CFX_ByteString::CFX_ByteString(char ch) { |
98 m_pData.Reset(StringData::Create(1)); | 107 m_pData.Reset(StringData::Create(1)); |
99 m_pData->m_String[0] = ch; | 108 m_pData->m_String[0] = ch; |
100 } | 109 } |
101 | 110 |
| 111 CFX_ByteString::CFX_ByteString(const FX_CHAR* ptr) |
| 112 : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {} |
| 113 |
102 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { | 114 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { |
103 if (!stringSrc.IsEmpty()) | 115 if (!stringSrc.IsEmpty()) |
104 m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); | 116 m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); |
105 } | 117 } |
106 | 118 |
107 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, | 119 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, |
108 const CFX_ByteStringC& str2) { | 120 const CFX_ByteStringC& str2) { |
109 int nNewLen = str1.GetLength() + str2.GetLength(); | 121 int nNewLen = str1.GetLength() + str2.GetLength(); |
110 if (nNewLen == 0) | 122 if (nNewLen == 0) |
111 return; | 123 return; |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 fraction %= scale; | 988 fraction %= scale; |
977 scale /= 10; | 989 scale /= 10; |
978 } | 990 } |
979 return buf_size; | 991 return buf_size; |
980 } | 992 } |
981 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { | 993 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { |
982 FX_CHAR buf[32]; | 994 FX_CHAR buf[32]; |
983 FX_STRSIZE len = FX_ftoa(d, buf); | 995 FX_STRSIZE len = FX_ftoa(d, buf); |
984 return CFX_ByteString(buf, len); | 996 return CFX_ByteString(buf, len); |
985 } | 997 } |
OLD | NEW |