Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  ParamTraits_STL.h   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 MOZILLA_PARAMTRAITS_STL_H
#define MOZILLA_PARAMTRAITS_STL_H

#include "ipc/IPCMessageUtils.h"
#include "mozilla/ipc/IPDLParamTraits.h"

#include <memory>

namespace IPC {

template <typename U, size_t N>
struct ParamTraits<std::array<U, N>> final {
  using T = std::array<U, N>;

  static void Write(MessageWriter* const writer, const T& in) {
    for (const auto& v : in) {
      WriteParam(writer, v);
    }
  }

  static bool Read(MessageReader* const reader, T* const out) {
    for (auto& v : *out) {
      if (!ReadParam(reader, &v)) return false;
    }
    return true;
  }
};

// -

template <typename U, size_t N>
struct ParamTraits<U[N]> final {
  using T = U[N];
  static constexpr size_t kByteSize = sizeof(U) * N;

  static_assert(std::is_trivial<U>::value);

  static void Write(MessageWriter* const writer, const T& in) {
    writer->WriteBytes(in, kByteSize);
  }

  static bool Read(MessageReader* const reader, T* const out) {
    if (!reader->HasBytesAvailable(kByteSize)) {
      return false;
    }
    return reader->ReadBytesInto(*out, kByteSize);
  }
};

// -

template <class U>
struct ParamTraits<std::optional<U>> final {
  using T = std::optional<U>;

  static void Write(MessageWriter* const writer, const T& in) {
    WriteParam(writer, bool{in});
    if (in) {
      WriteParam(writer, *in);
    }
  }

  static bool Read(MessageReader* const reader, T* const out) {
    bool isSome;
    if (!ReadParam(reader, &isSome)) return false;

    if (!isSome) {
      out->reset();
      return true;
    }
    out->emplace();
    return ReadParam(reader, &**out);
  }
};

}  // namespace IPC

#endif

Messung V0.5
C=90 H=95 G=92

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge