node/deps/icu-small/source/i18n/messageformat2_errors.h
Node.js GitHub Bot ab9660b55a
Some checks failed
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
License update / update_license (push) Has been cancelled
Find inactive collaborators / find (push) Has been cancelled
deps: update icu to 77.1
PR-URL: https://github.com/nodejs/node/pull/57455
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2025-03-16 20:10:32 +00:00

164 lines
4.8 KiB
C++

// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "unicode/utypes.h"
#ifndef U_HIDE_DEPRECATED_API
#ifndef MESSAGEFORMAT2_ERRORS_H
#define MESSAGEFORMAT2_ERRORS_H
#if U_SHOW_CPLUSPLUS_API
/**
* \file
* \brief C++ API: Formats messages using the draft MessageFormat 2.0.
*/
#if !UCONFIG_NO_NORMALIZATION
#if !UCONFIG_NO_FORMATTING
#if !UCONFIG_NO_MF2
#include "unicode/messageformat2_data_model_names.h"
#include "unicode/unistr.h"
#include "uvector.h"
U_NAMESPACE_BEGIN
namespace message2 {
using namespace data_model;
// Errors
// ----------
class DynamicErrors;
class StaticErrors;
// Internal class -- used as a private field in MessageFormatter
template <typename ErrorType>
class Error : public UObject {
public:
Error(ErrorType ty) : type(ty) {}
Error(ErrorType ty, const UnicodeString& s) : type(ty), contents(s) {}
virtual ~Error();
private:
friend class DynamicErrors;
friend class StaticErrors;
ErrorType type;
UnicodeString contents;
}; // class Error
enum StaticErrorType {
DuplicateDeclarationError,
DuplicateOptionName,
DuplicateVariant,
MissingSelectorAnnotation,
NonexhaustivePattern,
SyntaxError,
VariantKeyMismatchError
};
enum DynamicErrorType {
UnresolvedVariable,
FormattingError,
OperandMismatchError,
SelectorError,
UnknownFunction,
};
using StaticError = Error<StaticErrorType>;
using DynamicError = Error<DynamicErrorType>;
// These explicit instantiations have to come before the
// destructor definitions
template<>
Error<StaticErrorType>::~Error();
template<>
Error<DynamicErrorType>::~Error();
class StaticErrors : public UObject {
private:
friend class DynamicErrors;
LocalPointer<UVector> syntaxAndDataModelErrors;
bool dataModelError = false;
bool missingSelectorAnnotationError = false;
bool syntaxError = false;
public:
StaticErrors(UErrorCode&);
void setMissingSelectorAnnotation(UErrorCode&);
void setDuplicateOptionName(UErrorCode&);
void addSyntaxError(UErrorCode&);
bool hasDataModelError() const { return dataModelError; }
bool hasSyntaxError() const { return syntaxError; }
bool hasMissingSelectorAnnotationError() const { return missingSelectorAnnotationError; }
void addError(StaticError&&, UErrorCode&);
void checkErrors(UErrorCode&) const;
void clear();
const StaticError& first() const;
StaticErrors(const StaticErrors&, UErrorCode&);
StaticErrors(StaticErrors&&) noexcept;
virtual ~StaticErrors();
}; // class StaticErrors
class DynamicErrors : public UObject {
private:
const StaticErrors& staticErrors;
LocalPointer<UVector> resolutionAndFormattingErrors;
bool formattingError = false;
bool selectorError = false;
bool unknownFunctionError = false;
bool unresolvedVariableError = false;
public:
DynamicErrors(const StaticErrors&, UErrorCode&);
int32_t count() const;
void setSelectorError(const FunctionName&, UErrorCode&);
void setUnresolvedVariable(const VariableName&, UErrorCode&);
void setUnknownFunction(const FunctionName&, UErrorCode&);
void setFormattingError(const FunctionName&, UErrorCode&);
// Used when the name of the offending formatter is unknown
void setFormattingError(UErrorCode&);
void setOperandMismatchError(const FunctionName&, UErrorCode&);
bool hasDataModelError() const { return staticErrors.hasDataModelError(); }
bool hasFormattingError() const { return formattingError; }
bool hasSelectorError() const { return selectorError; }
bool hasSyntaxError() const { return staticErrors.hasSyntaxError(); }
bool hasUnknownFunctionError() const { return unknownFunctionError; }
bool hasMissingSelectorAnnotationError() const { return staticErrors.hasMissingSelectorAnnotationError(); }
bool hasUnresolvedVariableError() const { return unresolvedVariableError; }
void addError(DynamicError&&, UErrorCode&);
void checkErrors(UErrorCode&) const;
bool hasError() const;
bool hasStaticError() const;
const DynamicError& first() const;
virtual ~DynamicErrors();
}; // class DynamicErrors
} // namespace message2
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_MF2 */
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // MESSAGEFORMAT2_ERRORS_H
#endif // U_HIDE_DEPRECATED_API
// eof