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

Quelle  FormatBuffer.h   Sprache: C

 
/* 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/. */


#ifndef intl_components_FormatBuffer_h
#define intl_components_FormatBuffer_h

/**
 * This file contains public adaptors for the mozilla::intl Buffer template
 * argument. Adaptors that can automatically be deduced are kept as private
 * in ICU4CGlue.h. There is also the SpiderMonkey specific adaptor
 * js::intl::FormatBuffer in js/src/builtin/intl/FormatBuffer.h.
 */


#include "nsTString.h"

namespace mozilla::intl {

/**
 * mozilla::intl APIs require sizeable buffers. This class abstracts over
 * the nsTSubstring.
 */

template <typename T>
class nsTStringToBufferAdapter {
 public:
  using CharType = T;

  // Do not allow copy or move. Move could be added in the future if needed.
  nsTStringToBufferAdapter(const nsTStringToBufferAdapter&) = delete;
  nsTStringToBufferAdapter& operator=(const nsTStringToBufferAdapter&) = delete;

  explicit nsTStringToBufferAdapter(nsTSubstring<CharType>& aString)
      : mString(aString) {}

  /**
   * Ensures the buffer has enough space to accommodate |size| elements.
   */

  [[nodiscard]] bool reserve(size_t size) {
    return mString.SetLength(size, fallible);
  }

  /**
   * Returns the raw data inside the buffer.
   */

  CharType* data() { return mString.BeginWriting(); }

  /**
   * Returns the count of elements written into the buffer.
   */

  size_t length() const { return mString.Length(); }

  /**
   * Returns the buffer's overall capacity.
   */

  size_t capacity() const {
    // nsString's Capacity() method is protected, so just return the length.
    return mString.Length();
  }

  /**
   * Resizes the buffer to the given amount of written elements.
   */

  void written(size_t amount) {
    MOZ_ASSERT(amount <= mString.Length());
    // This sets |mString|'s internal size so that it matches how much was
    // written. This is necessary because the write happens across FFI
    // boundaries.
    mString.SetLength(amount);
  }

 private:
  nsTSubstring<CharType>& mString;
};

}  // namespace mozilla::intl

#endif /* intl_components_FormatBuffer_h */

Messung V0.5
C=93 H=85 G=88

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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 und die Messung sind noch experimentell.