Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // Copyright 2014 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 | |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 9 | #include "fxbarcode/utils.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 10 | |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 11 | bool BC_FX_ByteString_Replace(CFX_ByteString& dst, |
| 12 | uint32_t first, |
| 13 | uint32_t last, |
| 14 | int32_t count, |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 15 | char c) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | if (first > last || count <= 0) { |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 17 | return false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 18 | } |
| 19 | dst.Delete(first, last - first); |
| 20 | for (int32_t i = 0; i < count; i++) { |
Ryan Harrison | db14532 | 2017-08-02 14:44:17 -0400 | [diff] [blame] | 21 | dst.InsertAtFront(c); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 22 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 23 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 24 | } |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 25 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 26 | void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, char c) { |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 27 | for (int32_t i = 0; i < count; i++) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 28 | dst += c; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 29 | } |
tsepez | 82aa396 | 2017-01-20 12:59:50 -0800 | [diff] [blame] | 30 | void BC_FX_ByteString_Append(CFX_ByteString& dst, |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 31 | const std::vector<uint8_t>& ba) { |
| 32 | for (uint8_t value : ba) |
| 33 | dst += value; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 34 | } |