This file is indexed.

/usr/include/oce/NCollection_UtfString.lxx is in liboce-foundation-dev 0.17.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
// Created on: 2013-01-28
// Created by: Kirill GAVRILOV
// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

// =======================================================================
// function : strGetAdvance
// purpose  : Compute advance for specified string.
// =======================================================================
template<typename Type> template<typename TypeFrom> inline
void NCollection_UtfString<Type>::strGetAdvance (const TypeFrom*        theStringUtf,
                                                   const Standard_Integer theLengthMax,
                                                   Standard_Integer&      theSizeBytes,
                                                   Standard_Integer&      theLength)
{
  theSizeBytes = 0;
  theLength    = 0;
  NCollection_UtfIterator<TypeFrom> anIter (theStringUtf);
  const Standard_Integer aLengthMax = (theLengthMax > 0) ? theLengthMax : IntegerLast();
  switch (sizeof(Type))
  {
    case sizeof(Standard_Utf8Char):
    {
      for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
      {
        theSizeBytes += anIter.AdvanceBytesUtf8();
      }
      theLength = anIter.Index();
      return;
    }
    case sizeof(Standard_Utf16Char):
    {
      for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
      {
        theSizeBytes += anIter.AdvanceBytesUtf16();
      }
      theLength = anIter.Index();
      return;
    }
    case sizeof(Standard_Utf32Char):
    {
      for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
      {
        theSizeBytes += anIter.AdvanceBytesUtf32();
      }
      theLength = anIter.Index();
      return;
    }
    default: return;
  }
}

// =======================================================================
// function : GetChar
// purpose  :
// =======================================================================
template<typename Type>
Standard_Utf32Char NCollection_UtfString<Type>::GetChar (const Standard_Integer theCharIndex) const
{
  //Standard_ASSERT_SKIP (theCharIndex < myLength, "Out of range");
  NCollection_UtfIterator<Type> anIter (myString);
  for (; *anIter != 0; ++anIter)
  {
    if (anIter.Index() == theCharIndex)
    {
      return *anIter;
    }
  }
  return 0;
}

// =======================================================================
// function : GetCharBuffer
// purpose  :
// =======================================================================
template<typename Type>
const Type* NCollection_UtfString<Type>::GetCharBuffer (const Standard_Integer theCharIndex) const
{
  //Standard_ASSERT_SKIP(theCharIndex < myLength);
  NCollection_UtfIterator<Type> anIter (myString);
  for (; *anIter != 0; ++anIter)
  {
    if (anIter.Index() == theCharIndex)
    {
      return anIter.BufferHere();
    }
  }
  return NULL;
}

// =======================================================================
// function : Clear
// purpose  :
// =======================================================================
template<typename Type> inline
void NCollection_UtfString<Type>::Clear()
{
  strFree (myString);
  mySize   = 0;
  myLength = 0;
  myString = strAlloc (mySize);
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString()
: myString (strAlloc(0)),
  mySize   (0),
  myLength (0)
{
  //
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString (const NCollection_UtfString& theCopy)
: myString (strAlloc (theCopy.mySize)),
  mySize   (theCopy.mySize),
  myLength (theCopy.myLength)
{
  strCopy ((Standard_Byte* )myString, (const Standard_Byte* )theCopy.myString, mySize);
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString (const char*            theCopyUtf8,
                                                    const Standard_Integer theLength)
: myString (NULL),
  mySize   (0),
  myLength (0)
{
  FromUnicode (theCopyUtf8, theLength);
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString (const Standard_Utf16Char* theCopyUtf16,
                                                    const Standard_Integer    theLength)
: myString (NULL),
  mySize   (0),
  myLength (0)
{
  FromUnicode (theCopyUtf16, theLength);
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString (const Standard_Utf32Char* theCopyUtf32,
                                                    const Standard_Integer     theLength)
: myString (NULL),
  mySize   (0),
  myLength (0)
{
  FromUnicode (theCopyUtf32, theLength);
}

// =======================================================================
// function : NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::NCollection_UtfString (const Standard_WideChar* theCopyUtfWide,
                                                    const Standard_Integer   theLength)
: myString (NULL),
  mySize   (0),
  myLength (0)
{
  FromUnicode (theCopyUtfWide, theLength);
}

// =======================================================================
// function : ~NCollection_UtfString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>::~NCollection_UtfString()
{
  strFree (myString);
}

// =======================================================================
// function : operator=
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator= (const NCollection_UtfString<Type>& theOther)
{
  if (this == &theOther)
  {
    return (*this);
  }

  strFree (myString);
  mySize   = theOther.mySize;
  myLength = theOther.myLength;
  myString = strAlloc (mySize);
  strCopy ((Standard_Byte* )myString, (const Standard_Byte* )theOther.myString, mySize);
  return (*this);
}

// =======================================================================
// function : FromUnicode
// purpose  :
// =======================================================================
template<typename Type> template<typename TypeFrom>
void NCollection_UtfString<Type>::FromUnicode (const TypeFrom*        theStringUtf,
                                               const Standard_Integer theLength)
{
  Type* anOldBuffer = myString; // necessary in case of self-copying
  NCollection_UtfIterator<TypeFrom> anIterRead (theStringUtf);
  if (*anIterRead == 0)
  {
    // special case
    Clear();
    return;
  }

  switch (sizeof(TypeFrom)) // use switch() rather than if() to shut up msvc compiler
  {
    case sizeof(Type):
    {
      if (theLength > 0)
      {
        // optimized copy
        for(; *anIterRead != 0 && anIterRead.Index() < theLength; ++anIterRead) {}

        mySize   = Standard_Integer((Standard_Byte* )anIterRead.BufferHere() - (Standard_Byte* )theStringUtf);
        myLength = anIterRead.Index();
        myString = strAlloc (mySize);
        strCopy ((Standard_Byte* )myString, (const Standard_Byte* )theStringUtf, mySize);
        strFree (anOldBuffer);
        return;
      }
    }
    default: break;
  }

  strGetAdvance (theStringUtf, theLength, mySize, myLength);
  myString = strAlloc (mySize);
  // reset iterator
  anIterRead.Init (theStringUtf);
  Type* anIterWrite = myString;
  for (; *anIterRead != 0 && anIterRead.Index() < myLength; ++anIterRead)
  {
    anIterWrite = anIterRead.GetUtf (anIterWrite);
  }
  strFree (anOldBuffer);
}

// =======================================================================
// function : FromLocale
// purpose  :
// =======================================================================
template<typename Type> inline
void NCollection_UtfString<Type>::FromLocale (const char*            theString,
                                              const Standard_Integer theLength)
{
  #ifdef _MSC_VER 
  // use WinAPI
  int aWideSize = MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, theString, -1, NULL, 0);
  if (aWideSize <= 0)
  {
    Clear();
    return;
  }
  wchar_t* aWideBuffer = new wchar_t[aWideSize + 1];
  MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, theString, -1, aWideBuffer, aWideSize);
  aWideBuffer[aWideSize] = L'\0';
  FromUnicode (aWideBuffer, theLength);
  delete[] aWideBuffer;
#else
  // this is size in bytes but should probably be enough to store string in wide chars
  // notice that these functions are sensitive to locale set by application!
  int aMbLen = mblen (theString, MB_CUR_MAX);
  if (aMbLen <= 0)
  {
    Clear();
    return;
  }
  wchar_t* aWideBuffer = new wchar_t[aMbLen + 1];
  mbstowcs (aWideBuffer, theString, aMbLen);
  aWideBuffer[aMbLen] = L'\0';
  FromUnicode (aWideBuffer, theLength);
  delete[] aWideBuffer;
#endif
}

// =======================================================================
// function : ToLocale
// purpose  :
// =======================================================================
template<typename Type> inline
bool NCollection_UtfString<Type>::ToLocale (char*                  theBuffer,
                                            const Standard_Integer theSizeBytes) const
{
  NCollection_UtfString<wchar_t> aWideCopy (myString, myLength);
#ifdef _MSC_VER 
  int aMbBytes = WideCharToMultiByte (CP_ACP, 0, aWideCopy.ToCString(), -1, theBuffer, theSizeBytes, NULL, NULL);
#else
  std::size_t aMbBytes = std::wcstombs (theBuffer, aWideCopy.ToCString(), theSizeBytes);
#endif
  if (aMbBytes <= 0)
  {
    *theBuffer = '\0';
    return false;
  }
  return true;
}

// =======================================================================
// function : operator=
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator= (const char* theStringUtf8)
{
  FromUnicode (theStringUtf8);
  return (*this);
}

// =======================================================================
// function : operator=
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator= (const Standard_WideChar* theStringUtfWide)
{
  FromUnicode (theStringUtfWide);
  return (*this);
}

// =======================================================================
// function : IsEqual
// purpose  :
// =======================================================================
template<typename Type> inline
bool NCollection_UtfString<Type>::IsEqual (const NCollection_UtfString& theCompare) const
{
  return this == &theCompare
      || strAreEqual (myString, mySize, theCompare.myString, theCompare.mySize);
}

// =======================================================================
// function : operator!=
// purpose  :
// =======================================================================
template<typename Type> inline
bool NCollection_UtfString<Type>::operator!= (const NCollection_UtfString& theCompare) const
{
  return (!NCollection_UtfString::operator== (theCompare));
}

// =======================================================================
// function : operator+=
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator+= (const NCollection_UtfString<Type>& theAppend)
{
  if (theAppend.IsEmpty())
  {
    return (*this);
  }

  // create new string
  Standard_Integer aSize = mySize + theAppend.mySize;
  Type* aString = strAlloc (aSize);
  strCopy ((Standard_Byte* )aString,          (const Standard_Byte* )myString,           mySize);
  strCopy ((Standard_Byte* )aString + mySize, (const Standard_Byte* )theAppend.myString, theAppend.mySize);

  strFree (myString);
  mySize   = aSize;
  myString = aString;
  myLength += theAppend.myLength;
  return (*this);
}

// =======================================================================
// function : SubString
// purpose  :
// =======================================================================
template<typename Type> inline
NCollection_UtfString<Type> NCollection_UtfString<Type>::SubString (const Standard_Integer theStart,
                                                                    const Standard_Integer theEnd) const
{
  if (theStart >= theEnd)
  {
    return NCollection_UtfString<Type>();
  }
  for (NCollection_UtfIterator<Type> anIter(myString); *anIter != 0; ++anIter)
  {
    if (anIter.Index() >= theStart)
    {
      return NCollection_UtfString<Type> (anIter.BufferHere(), theEnd - theStart);
    }
  }
  return NCollection_UtfString<Type>();
}

// =======================================================================
// function : ToUtf8
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Standard_Utf8Char> NCollection_UtfString<Type>::ToUtf8() const
{
  NCollection_UtfString<Standard_Utf8Char> aCopy;
  aCopy.FromUnicode (myString);
  return aCopy;
}

// =======================================================================
// function : ToUtf16
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Standard_Utf16Char> NCollection_UtfString<Type>::ToUtf16() const
{
  NCollection_UtfString<Standard_Utf16Char> aCopy;
  aCopy.FromUnicode (myString);
  return aCopy;
}

// =======================================================================
// function : ToUtf32
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Standard_Utf32Char> NCollection_UtfString<Type>::ToUtf32() const
{
  NCollection_UtfString<Standard_Utf32Char> aCopy;
  aCopy.FromUnicode (myString);
  return aCopy;
}

// =======================================================================
// function : ToUtfWide
// purpose  :
// =======================================================================
template<typename Type> inline
const NCollection_UtfString<Standard_WideChar> NCollection_UtfString<Type>::ToUtfWide() const
{
  NCollection_UtfString<Standard_WideChar> aCopy;
  aCopy.FromUnicode (myString);
  return aCopy;
}