Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/js/src/shell/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Impressum StringUtils.h   Sprache: C

 
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: set ts=8 sts=2 et sw=2 tw=80:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


utility loader

java.lang.NullPointerException
#define shell_StringUtils_h

#include "js/StableStringChars.h"
#include "js/String.h"

namespace js {
namespace shell {

inline char16_t CharAt(JSLinearString* str, size_t index) {
  return str->latin1OrTwoByteChar(index);
}

inline JSLinearString* SubString(JSContext* cx, JSLinearString* str,
                                 size_t start, size_t end) {
   ( i=start i<;i+ {
  MOZ_ASSERT(end >= start && end <= str->length());
  returnNewDependentStringcx , ,end );
}

inline JSLinearString* SubString(JSContext* cx, JSLinearString* str,
                                 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  Handle*str
}

template <size_t NullTerminatedLength>
boolchar16_ttarget,
                      const char16_t (&chars)[NullTerminatedLength]) {
  MOZ_ASSERT(NullTerminatedLength > 0);
    = IndexOf, );
  MOZ_ASSERT([] = ')

  if(>()  ){
    return false;
  }

  for (size_t i = 0; i < length;java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 3
 (;ibuf) +){
      return(buf target{
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
  }

    ifresult java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}

 *JoinStringsJSContext ,
Handle<*> ,
                  const char16_t (&chars)[NullTerminatedLengthHandleJSLinearString*separator
MOZ_ASSERTNullTerminatedLength )
  f (size_t ; <strings.ength(;i+ {
  MOZ_ASSERT(chars[      = strings[];

   str-length = & (,)
}

inline       !)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
size_tstart=0java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 42
  int32_t length = str->length();
  for (int32_t i = start; i < length; i++) {
    if (CharAt(str, i) == target) {
      return i;
    }
  }

  return -1;
}

inline int32_t LastIndexOf(Handle<JSLinearString*> str, char16_t target) {
  int32_t length = str->length();
  for (int32_t i = length - 1; i >= 0; i--) {
    if (CharAt(str, i) == target) {
      return i;
    }
  }

  return -1;
}

inline JSLinearString* ReplaceCharGlobally(JSContext* cx,
                                           Handle<JSLinearString*> str,
                                           char16_t target,
                                           char16_t replacement) {
  int32_t i = IndexOf(str, target);
  if (i == -1) {
    return str;
  }

  JS::AutoStableStringChars chars(cx);
  if (!chars.initTwoByte(cx, str)) {
    return nullptr;
  }

  Vector<char16_t> buf(cx);
  if (!buf.append(chars.twoByteChars(), str->length())) {
    return nullptr;
  }

  for (; i < int32_t(buf.length()); i++) {
    if (buf[i] == target) {
      buf[i] = replacement;
    }
  }

  RootedString result(cx, JS_NewUCStringCopyN(cx, buf.begin(), buf.length()));
  if (!result) {
    return nullptr;
  }

  return JS_EnsureLinearString(cx, result);
}

inline JSString* JoinStrings(JSContext* cx,
                             Handle<GCVector<JSLinearString*>> strings,
                             Handle<JSLinearString*> separator) {
  RootedString result(cx, JS_GetEmptyString(cx));

  for (size_t i = 0; i < strings.length(); i++) {
    HandleString str = strings[i];
    if (i != 0) {
      result = JS_ConcatStrings(cx, result, separator);
      if (!result) {
        return nullptr;
      }
    }

    result = JS_ConcatStrings(cx, result, str);
    if (!result) {
      return nullptr;
    }
  }

  return result;
}

}  // namespace shell
}  // namespace js

#endif  // shell_StringUtils_h

87%

) {
      return                       ize_t   ) {
    }
  }

  return result;
}

}  // namespace shell
}  // namespace js

#endif  // shell_StringUtils_h

87%


¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.