Line data Source code
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 : #ifndef TRANSFRMX_TXXSLTNUMBER_H
7 : #define TRANSFRMX_TXXSLTNUMBER_H
8 :
9 : #include "nsError.h"
10 : #include "txList.h"
11 : #include "nsString.h"
12 :
13 : class Expr;
14 : class txPattern;
15 : class txIEvalContext;
16 : class txIMatchContext;
17 : class txXPathTreeWalker;
18 :
19 : class txXSLTNumber {
20 : public:
21 : enum LevelType {
22 : eLevelSingle,
23 : eLevelMultiple,
24 : eLevelAny
25 : };
26 :
27 : static nsresult createNumber(Expr* aValueExpr, txPattern* aCountPattern,
28 : txPattern* aFromPattern, LevelType aLevel,
29 : Expr* aGroupSize, Expr* aGroupSeparator,
30 : Expr* aFormat, txIEvalContext* aContext,
31 : nsAString& aResult);
32 :
33 : private:
34 : static nsresult getValueList(Expr* aValueExpr, txPattern* aCountPattern,
35 : txPattern* aFromPattern, LevelType aLevel,
36 : txIEvalContext* aContext, txList& aValues,
37 : nsAString& aValueString);
38 :
39 : static nsresult getCounters(Expr* aGroupSize, Expr* aGroupSeparator,
40 : Expr* aFormat, txIEvalContext* aContext,
41 : txList& aCounters, nsAString& aHead,
42 : nsAString& aTail);
43 :
44 : /**
45 : * getSiblingCount uses aWalker to walk the siblings of aWalker's current
46 : * position.
47 : *
48 : */
49 : static nsresult getSiblingCount(txXPathTreeWalker& aWalker,
50 : txPattern* aCountPattern,
51 : txIMatchContext* aContext,
52 : int32_t* aCount);
53 :
54 : static bool getPrevInDocumentOrder(txXPathTreeWalker& aWalker);
55 :
56 : static bool isAlphaNumeric(char16_t ch);
57 : };
58 :
59 0 : class txFormattedCounter {
60 : public:
61 0 : virtual ~txFormattedCounter()
62 0 : {
63 0 : }
64 :
65 : virtual void appendNumber(int32_t aNumber, nsAString& aDest) = 0;
66 :
67 : static nsresult getCounterFor(const nsString& aToken, int aGroupSize,
68 : const nsAString& aGroupSeparator,
69 : txFormattedCounter*& aCounter);
70 :
71 : nsString mSeparator;
72 : };
73 :
74 : #endif //TRANSFRMX_TXXSLTNUMBER_H
|