File: format.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (198 lines) | stat: -rw-r--r-- 8,784 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-runtime-lib
 * Created on: 25 февр. 2020 г.
 *
 * lsp-runtime-lib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-runtime-lib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_EXPR_FORMAT_H_
#define LSP_PLUG_IN_EXPR_FORMAT_H_

#include <lsp-plug.in/runtime/version.h>
#include <lsp-plug.in/io/IOutSequence.h>
#include <lsp-plug.in/io/IInSequence.h>
#include <lsp-plug.in/expr/Parameters.h>

namespace lsp
{
    namespace expr
    {
        /**
         * Format string syntax:
         *   format-string: element
         *   element: { character | escape_sequence | format_specifier } [element]
         *   character: any character except '\', '{', '}'
         *   escape_sequence: '\' { '\' | '{' | '}' }
         *   format_specifier: '{' format_description '}'
         *   format_description: modifiers
         *   modifiers: { parameter_name | parameter_index | padding | alignment | type | width } [ modifiers ]
         *   parameter_name: '@' identifier_first [identifier_next]
         *   parameter_index: '[' parameter_number ']'
         *   padding: { padding_left | padding_right }
         *   alignment: { align_left | align_to_left | align_from_left | align_middle | align_from_right | align_to_right | align_right }
         *   type: '%' [ type_sign ] [ type_width ] [ type_specifier ]
         *   width: ':' decimal_digits
         *   identifier_first: any character of 'a'-'z', 'A'-'Z' and '_'
         *   identifier_next: { identifier_first | '0'-'9' } [ identifier_next ]
         *   parameter_number: decimal_digits
         *   decimal_digits: '0'-'9' [ decimal_digits ]
         *   padding_left: '^' character
         *   padding_right: '$' character
         *   character: any possible character except '\0'
         *   align_left: '<'
         *   align_to_left: '<' '|'
         *   align_from_left: '>' '|'
         *   align_middle: '|'
         *   align_from_right: '|' '<'
         *   align_to_right: '|' '>'
         *   align_right: '>'
         *   type_sign: '+'
         *   type_width: decimal_digits [ type_fraction ]
         *   type_fraction: '.' decimal_digits
         *   type_specifier: '%' { decimal_type | float_type | binary_type | octal_type | hexadecimal_type | boolean_type | string_type | text_type }
         *   decimal_type: { 'i' | 'd' | 'u' }
         *   float_type: { 'f' | 'F' | 'e' | 'E' }
         *   binary_type: 'b'
         *   octal_type: 'o'
         *   hexadecimal_type: { 'x' | 'X' }
         *   boolean_type: { 'l' | 'L' } [ { 'l' | 'L' } ]
         *   string_type: 's'
         *   text_type: { 't' | 'T' } [ { 't' | 'T' } ]
         *
         * Example formats:
         *   "The value with name 'x' is: {@x}"
         *   "The value with index 1 is: {[1]}"
         *   "The zero-padded integer from left is: {>^0@x}"
         *   "The hex integer from left is: {>^0@x}"
         *   "The 8-digit octal number inside of underscored field of 16 digits aligned to center: {|^_%8o:16$_}"
         *
         * Each format specifier can contain:
         *   Parameter reference:
         *     - named: {@parameter}
         *     - indexed: [parameter_index]
         *   Padding character specification:
         *     - preceding character: ^character
         *     - subsequent character: $character
         *   Alignment:
         *     - left alignment: <
         *     - right alignment: >
         *     - middle alignment: |
         *     - middle alignment with left offset: <|
         *     - middle alignment with right offset: |>
         *     - left alignment with 1/4 offset: |<
         *     - right alignment with 1/4 offset: >|
         *   Type specifier:
         *     - permanent sign presence flag: +
         *     - value width - minimum number of digits (including dot character for floating point values)
         *     - fraction width (number of fraction digits for floating point values)
         *     - data type specifier:
         *       - E: exponential floating point value upper-case 'INF' and 'NAN' values
         *       - F: floating point value with upper-case 'INF' and 'NAN' values
         *       - L: upper-case boolean value ('TRUE' and 'FALSE')
         *       - Ll: camel-case boolean value ('True' and 'False')
         *       - S: string (same as s)
         *       - T: text, all characters in upper-case
         *       - Tt: text, first character in upper-case, all others in lower-case
         *       - X: upper-case hexadecimal integers
         *       - b: binary integers
         *       - d: decimal integers (same to i)
         *       - e: exponential floating point value lower-case 'inf' and 'nan' values
         *       - f: floating point value with lower-case 'inf' and 'nan' values
         *       - i: decimal integers (same to d)
         *       - l: lower-case boolean value ('true' and 'false')
         *       - lL: reverse camel-case boolean value ('tRUE' and 'fALSE')
         *       - o: octal integers
         *       - s: string (same as S)
         *       - t: text, all characters in lower-case
         *       - tT: text, first character in lower-case, all others in upper-case
         *       - u: unsigned integers
         *       - x: lower-case hexadecimal integers
         *   Width specifier - the minimum number of characters to allocate for printing the value
         *
         */

        /**
         * Format the set of parameters provided by Resolver using input character
         * sequence as format specifier and output the result to output character
         * sequence
         *
         * @param out output character sequence
         * @param fmt format specifier
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(io::IOutSequence *out, io::IInSequence *fmt, const Parameters *r);

        /**
         * Format the set of parameters provided by Resolver using format string
         * and output the result to output character sequence
         *
         * @param out output character sequence
         * @param fmt format specifier (UTF-8 character sequence)
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(io::IOutSequence *out, const char *fmt, const Parameters *r);

        /**
         * Format the set of parameters provided by Resolver using format string
         * and output the result to output character sequence
         *
         * @param out output character sequence
         * @param fmt format specifier
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(io::IOutSequence *out, const LSPString *fmt, const Parameters *r);

        /**
         * Format the set of parameters provided by Resolver using input character
         * sequence as format specifier and output the result to string
         *
         * @param out output string
         * @param fmt format specifier
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(LSPString *out, io::IInSequence *fmt, const Parameters *r);

        /**
         * Format the set of parameters provided by Resolver using format string
         * and output the result to string
         *
         * @param out output string
         * @param fmt format specifier (UTF-8 character sequence)
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(LSPString *out, const char *fmt, const Parameters *r);

        /**
         * Format the set of parameters provided by Resolver using format string
         * and output the result to string
         *
         * @param out output string
         * @param fmt format specifier
         * @param r parameter resolver
         * @return status of operation
         */
        status_t format(LSPString *out, const LSPString *fmt, const Parameters *r);
    }
}


#endif /* LSP_PLUG_IN_EXPR_FORMAT_H_ */