Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/xml/txXMLUtils.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
/**
7
 * An XML Utility class
8
**/
9
10
#ifndef MITRE_XMLUTILS_H
11
#define MITRE_XMLUTILS_H
12
13
#include "txCore.h"
14
#include "nsDependentSubstring.h"
15
#include "txXPathNode.h"
16
17
0
#define kExpatSeparatorChar 0xFFFF
18
19
extern "C" int MOZ_XMLIsLetter(const char* ptr);
20
extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
21
22
class nsAtom;
23
24
class XMLUtils {
25
26
public:
27
    static nsresult splitExpatName(const char16_t *aExpatName,
28
                                   nsAtom **aPrefix, nsAtom **aLocalName,
29
                                   int32_t* aNameSpaceID);
30
    static nsresult splitQName(const nsAString& aName, nsAtom** aPrefix,
31
                               nsAtom** aLocalName);
32
33
    /*
34
     * Returns true if the given character is whitespace.
35
     */
36
    static bool isWhitespace(const char16_t& aChar)
37
0
    {
38
0
        return (aChar <= ' ' &&
39
0
                (aChar == ' ' || aChar == '\r' ||
40
0
                 aChar == '\n'|| aChar == '\t'));
41
0
    }
42
43
    /**
44
     * Returns true if the given string has only whitespace characters
45
     */
46
    static bool isWhitespace(const nsAString& aText);
47
48
    /**
49
     * Normalizes the value of a XML processingInstruction
50
    **/
51
    static void normalizePIValue(nsAString& attValue);
52
53
    /**
54
     * Returns true if the given string is a valid XML QName
55
     */
56
    static bool isValidQName(const nsAString& aQName, const char16_t** aColon);
57
58
    /**
59
     * Returns true if the given character represents an Alpha letter
60
     */
61
    static bool isLetter(char16_t aChar)
62
0
    {
63
0
        return !!MOZ_XMLIsLetter(reinterpret_cast<const char*>(&aChar));
64
0
    }
65
66
    /**
67
     * Returns true if the given character is an allowable NCName character
68
     */
69
    static bool isNCNameChar(char16_t aChar)
70
0
    {
71
0
        return !!MOZ_XMLIsNCNameChar(reinterpret_cast<const char*>(&aChar));
72
0
    }
73
74
    /*
75
     * Walks up the document tree and returns true if the closest xml:space
76
     * attribute is "preserve"
77
     */
78
    static bool getXMLSpacePreserve(const txXPathNode& aNode);
79
};
80
81
#endif