blob: 1d09e247365ffa802db1deb9fd3064b074b996c6 [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
Ryan Harrison275e2602017-09-18 14:23:18 -040011bool BC_FX_ByteString_Replace(ByteString& dst,
tsepezd19e9122016-11-02 15:43:18 -070012 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
Ryan Harrison275e2602017-09-18 14:23:18 -040026void BC_FX_ByteString_Append(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}
Ryan Harrison275e2602017-09-18 14:23:18 -040030void BC_FX_ByteString_Append(ByteString& dst, const std::vector<uint8_t>& ba) {
Tom Sepez8b6186f2017-03-28 12:06:45 -070031 for (uint8_t value : ba)
32 dst += value;
Dan Sinclair1770c022016-03-14 14:14:16 -040033}