blob: 284322e8327bb385b2a0353dc728fc7666bccb22 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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 Sepez8b6186f2017-03-28 12:06:45 -07007#include <vector>
8
Dan Sinclaire7786682017-03-29 15:18:41 -04009#include "fxbarcode/utils.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040010
tsepezd19e9122016-11-02 15:43:18 -070011bool BC_FX_ByteString_Replace(CFX_ByteString& dst,
12 uint32_t first,
13 uint32_t last,
14 int32_t count,
Dan Sinclair812e96c2017-03-13 16:43:37 -040015 char c) {
Dan Sinclair1770c022016-03-14 14:14:16 -040016 if (first > last || count <= 0) {
tsepezd19e9122016-11-02 15:43:18 -070017 return false;
Dan Sinclair1770c022016-03-14 14:14:16 -040018 }
19 dst.Delete(first, last - first);
20 for (int32_t i = 0; i < count; i++) {
Ryan Harrisondb145322017-08-02 14:44:17 -040021 dst.InsertAtFront(c);
Dan Sinclair1770c022016-03-14 14:14:16 -040022 }
tsepezd19e9122016-11-02 15:43:18 -070023 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040024}
Tom Sepez8b6186f2017-03-28 12:06:45 -070025
Dan Sinclair812e96c2017-03-13 16:43:37 -040026void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, char c) {
Tom Sepez8b6186f2017-03-28 12:06:45 -070027 for (int32_t i = 0; i < count; i++)
Dan Sinclair1770c022016-03-14 14:14:16 -040028 dst += c;
Dan Sinclair1770c022016-03-14 14:14:16 -040029}
tsepez82aa3962017-01-20 12:59:50 -080030void BC_FX_ByteString_Append(CFX_ByteString& dst,
Tom Sepez8b6186f2017-03-28 12:06:45 -070031 const std::vector<uint8_t>& ba) {
32 for (uint8_t value : ba)
33 dst += value;
Dan Sinclair1770c022016-03-14 14:14:16 -040034}