blob: 3c7540642501da62e03baf39b3aeb070498b2294 [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
dsinclaira52ab742016-09-29 13:59:29 -07009#include "core/fxcrt/fx_basic.h"
Dan Sinclaire7786682017-03-29 15:18:41 -040010#include "fxbarcode/utils.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040011
tsepezd19e9122016-11-02 15:43:18 -070012bool BC_FX_ByteString_Replace(CFX_ByteString& dst,
13 uint32_t first,
14 uint32_t last,
15 int32_t count,
Dan Sinclair812e96c2017-03-13 16:43:37 -040016 char c) {
Dan Sinclair1770c022016-03-14 14:14:16 -040017 if (first > last || count <= 0) {
tsepezd19e9122016-11-02 15:43:18 -070018 return false;
Dan Sinclair1770c022016-03-14 14:14:16 -040019 }
20 dst.Delete(first, last - first);
21 for (int32_t i = 0; i < count; i++) {
22 dst.Insert(0, c);
23 }
tsepezd19e9122016-11-02 15:43:18 -070024 return true;
Dan Sinclair1770c022016-03-14 14:14:16 -040025}
Tom Sepez8b6186f2017-03-28 12:06:45 -070026
Dan Sinclair812e96c2017-03-13 16:43:37 -040027void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, char c) {
Tom Sepez8b6186f2017-03-28 12:06:45 -070028 for (int32_t i = 0; i < count; i++)
Dan Sinclair1770c022016-03-14 14:14:16 -040029 dst += c;
Dan Sinclair1770c022016-03-14 14:14:16 -040030}
tsepez82aa3962017-01-20 12:59:50 -080031void BC_FX_ByteString_Append(CFX_ByteString& dst,
Tom Sepez8b6186f2017-03-28 12:06:45 -070032 const std::vector<uint8_t>& ba) {
33 for (uint8_t value : ba)
34 dst += value;
Dan Sinclair1770c022016-03-14 14:14:16 -040035}