diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-11-30 19:24:40 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-11-30 19:24:40 +0000 |
commit | 0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7 (patch) | |
tree | 14951a51950dffbe094b6cdd3fd56d239b1079f2 /src/minimacro.h | |
parent | 4d0a7466320e54f45f413efef09ef8e6ad21bb3e (diff) | |
download | libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.gz libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.bz2 libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.xz libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.zip |
Fixed the overshoot in the Bu::TafReader, it was reading the lookahead character
from the stream even when it should have known it was at the end, and then it
was reading an extra character after that anyway :-P It is now fixed, and the
stream is positioned at the character immediately after the closing } of the
root taf group, great for things like the svtools.
Diffstat (limited to '')
-rw-r--r-- | src/minimacro.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/minimacro.h b/src/minimacro.h new file mode 100644 index 0000000..e136015 --- /dev/null +++ b/src/minimacro.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_MINI_MACRO_H | ||
9 | #define BU_MINI_MACRO_H | ||
10 | |||
11 | namespace Bu | ||
12 | { | ||
13 | /** | ||
14 | * A processor for Libbu++ brand Mini Macros. These are really simple, but | ||
15 | * still fairly flexible. It's mainly text replacement, but with a few | ||
16 | * extras like filter functions and conditional text segments. So far we | ||
17 | * don't support loops or anything, I'm not sure we ever will. | ||
18 | * | ||
19 | * Anatomy of a mini macro: | ||
20 | * - Every macro begins with a two character code, the first character is | ||
21 | * always '{', the second character determines the operation to perform. | ||
22 | * - If the '{' is followed by a character that is not valid it is not | ||
23 | * considered for expansion and the characters are copied to the output. | ||
24 | * - Every macro ends with a closing '}' | ||
25 | * - Macro types: | ||
26 | * - '=': variable replacement. The '=' is immediatley followed by the | ||
27 | * name of the variable to replace, then any number of optional filter | ||
28 | * segments. | ||
29 | * - '?': conditional text. The '?' is immediately followed by the | ||
30 | * variable to test. This works two ways, the variable can be alone, in | ||
31 | * which case it's existance is tested, or it can be followed by a "=" | ||
32 | * and a string to compare to. This is then followed by a text segment | ||
33 | * that will be used if the test is true, and an optional text segment | ||
34 | * to be used if the test is false. | ||
35 | * - Segments: | ||
36 | * - Each segment is seperated by a colon. | ||
37 | * - Filter segments give the name of the filter, followed by | ||
38 | * parenthesies. Parameters may be provided within the parenthesies. | ||
39 | * - Text segments should always be quoted, but may contain any characters | ||
40 | * within the quotes, backslash is used as per C/ANSI/ISO standard. | ||
41 | * You can also quote any text using [" "] instead of quotes, which | ||
42 | * allows for nested strings. The [" token is only recognised within | ||
43 | * a macro. | ||
44 | * | ||
45 | *@verbatim | ||
46 | {=name:tolower()} | ||
47 | {=name:ccsplit("_"):toupper()} | ||
48 | {?name:"name exists and is {=name}"} | ||
49 | {?name:"{=name}":"no name!"} | ||
50 | {?name="bob":"You're named bob!":"Who are you? I only know bob..."} | ||
51 | @endverbatim | ||
52 | */ | ||
53 | class MiniMacro | ||
54 | { | ||
55 | public: | ||
56 | MiniMacro(); | ||
57 | virtual ~MiniMacro(); | ||
58 | |||
59 | private: | ||
60 | }; | ||
61 | }; | ||
62 | |||
63 | #endif | ||