/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsASCIIMask_h_ #define nsASCIIMask_h_
#include <array> #include <cstdint>
#include"mozilla/Attributes.h"
typedef std::array<bool, 128> ASCIIMaskArray;
namespace mozilla {
// Boolean arrays, fixed size and filled in at compile time, meant to // record something about each of the (standard) ASCII characters. // No extended ASCII for now, there has been no use case. // If you have loops that go through a string character by character // and test for equality to a certain set of characters before deciding // on a course of action, chances are building up one of these arrays // and using it is going to be faster, especially if the set of // characters is more than one long, and known at compile time. class ASCIIMask {
public: // Preset masks for some common character groups // When testing, you must check if the index is < 128 or use IsMasked() // // if (someChar < 128 && MaskCRLF()[someChar]) this is \r or \n
// Outside of the preset ones, use these templates to create more masks. // // The example creation will look like this: // // constexpr bool TestABC(char c) { return c == 'A' || c == 'B' || c == 'C'; } // constexpr std::array<bool, 128> sABCMask = CreateASCIIMask(TestABC); // ... // if (someChar < 128 && sABCMask[someChar]) this is A or B or C
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.