Coverage Report

Created: 2025-09-05 07:16

/src/icu/icu4c/source/i18n/messageformat2_arguments.cpp
Line
Count
Source (jump to first uncovered line)
1
// © 2024 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
4
#include "unicode/utypes.h"
5
6
#if !UCONFIG_NO_NORMALIZATION
7
8
#if !UCONFIG_NO_FORMATTING
9
10
#if !UCONFIG_NO_MF2
11
12
#include "unicode/messageformat2.h"
13
#include "unicode/messageformat2_arguments.h"
14
#include "unicode/messageformat2_data_model_names.h"
15
#include "messageformat2_evaluation.h"
16
#include "messageformat2_function_registry_internal.h"
17
#include "uvector.h" // U_ASSERT
18
19
U_NAMESPACE_BEGIN
20
21
namespace message2 {
22
23
    using namespace data_model;
24
25
    // ------------------------------------------------------
26
    // MessageArguments
27
28
    using Arguments = MessageArguments;
29
30
    const Formattable* Arguments::getArgument(const VariableName& arg,
31
0
                                              UErrorCode& errorCode) const {
32
0
        if (U_SUCCESS(errorCode)) {
33
0
            U_ASSERT(argsLen == 0 || arguments.isValid());
34
0
            for (int32_t i = 0; i < argsLen; i++) {
35
0
                UnicodeString normalized = StandardFunctions::normalizeNFC(argumentNames[i]);
36
                // arg already assumed to be normalized
37
0
                if (normalized == arg) {
38
0
                    return &arguments[i];
39
0
                }
40
0
            }
41
0
            errorCode = U_ILLEGAL_ARGUMENT_ERROR;
42
0
        }
43
0
        return nullptr;
44
0
    }
45
46
0
    MessageArguments::~MessageArguments() {}
47
48
    // Message arguments
49
    // -----------------
50
51
0
    MessageArguments& MessageArguments::operator=(MessageArguments&& other) noexcept {
52
0
        U_ASSERT(other.arguments.isValid() || other.argsLen == 0);
53
0
        argsLen = other.argsLen;
54
0
        if (argsLen != 0) {
55
0
            argumentNames.adoptInstead(other.argumentNames.orphan());
56
0
            arguments.adoptInstead(other.arguments.orphan());
57
0
        }
58
0
        return *this;
59
0
    }
60
61
} // namespace message2
62
63
U_NAMESPACE_END
64
65
#endif /* #if !UCONFIG_NO_MF2 */
66
67
#endif /* #if !UCONFIG_NO_FORMATTING */
68
69
#endif /* #if !UCONFIG_NO_NORMALIZATION */