• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 #include <vector>
8 
9 #include "fxbarcode/utils.h"
10 
BC_FX_ByteString_Replace(ByteString & dst,uint32_t first,uint32_t last,int32_t count,char c)11 bool BC_FX_ByteString_Replace(ByteString& dst,
12                               uint32_t first,
13                               uint32_t last,
14                               int32_t count,
15                               char c) {
16   if (first > last || count <= 0) {
17     return false;
18   }
19   dst.Delete(first, last - first);
20   for (int32_t i = 0; i < count; i++) {
21     dst.InsertAtFront(c);
22   }
23   return true;
24 }
25 
BC_FX_ByteString_Append(ByteString & dst,int32_t count,char c)26 void BC_FX_ByteString_Append(ByteString& dst, int32_t count, char c) {
27   for (int32_t i = 0; i < count; i++)
28     dst += c;
29 }
BC_FX_ByteString_Append(ByteString & dst,const std::vector<uint8_t> & ba)30 void BC_FX_ByteString_Append(ByteString& dst, const std::vector<uint8_t>& ba) {
31   for (uint8_t value : ba)
32     dst += value;
33 }
34