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/. */
6 #ifndef mozilla_CharTokenizer_h
7 #define mozilla_CharTokenizer_h
9 #include "nsDependentSubstring.h"
13 template<PRUnichar delimiter
>
17 CharTokenizer(const nsSubstring
& aSource
)
19 aSource
.BeginReading(mIter
);
20 aSource
.EndReading(mEnd
);
24 * Checks if any more tokens are available.
32 * Returns the next token.
34 const nsDependentSubstring
nextToken()
36 nsSubstring::const_char_iterator begin
= mIter
;
37 while (mIter
!= mEnd
&& (*mIter
) != delimiter
) {
40 nsSubstring::const_char_iterator end
= mIter
;
45 return Substring(begin
, end
);
49 nsSubstring::const_char_iterator mIter
, mEnd
;
52 template<char delimiter
>
56 CCharTokenizer(const nsCSubstring
& aSource
)
58 aSource
.BeginReading(mIter
);
59 aSource
.EndReading(mEnd
);
63 * Checks if any more tokens are available.
71 * Returns the next token.
73 const nsDependentCSubstring
nextToken()
75 nsCSubstring::const_char_iterator begin
= mIter
;
76 while (mIter
!= mEnd
&& (*mIter
) != delimiter
) {
79 nsCSubstring::const_char_iterator end
= mIter
;
84 return Substring(begin
, end
);
88 nsCSubstring::const_char_iterator mIter
, mEnd
;
91 } // namespace mozilla
93 #endif /* mozilla_CharTokenizer_h */