No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / src / read-po-abstract.h
blob62a43204e8c812e5459aa19ef8f745b5a149b3a3
1 /* Reading PO files, abstract class.
2 Copyright (C) 1995-1996, 1998, 2000-2003, 2005 Free Software Foundation, Inc.
4 This file was written by Peter Miller <millerp@canb.auug.org.au>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #ifndef _READ_PO_ABSTRACT_H
21 #define _READ_PO_ABSTRACT_H
23 #include "po-lex.h"
24 #include "message.h"
26 #include <stdbool.h>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
34 /* Note: the _t suffix is reserved by ANSI C, so the _ty suffix is
35 used to indicate a type name. */
37 /* The following pair of structures cooperate to create an "Object" in
38 the OO sense. We are simply doing it manually, rather than with the
39 help of an OO compiler. This implementation allows polymorphism
40 and inheritance - more than enough for the immediate needs. */
42 /* Forward declaration. */
43 struct abstract_po_reader_ty;
46 /* This first structure, playing the role of the "Class" in OO sense,
47 contains pointers to functions. Each function is a method for the
48 class (base or derived). Use a NULL pointer where no action is
49 required. */
51 typedef struct abstract_po_reader_class_ty abstract_po_reader_class_ty;
52 struct abstract_po_reader_class_ty
54 /* how many bytes to malloc for an instance of this class */
55 size_t size;
57 /* what to do immediately after the instance is malloc()ed */
58 void (*constructor) (struct abstract_po_reader_ty *pop);
60 /* what to do immediately before the instance is free()ed */
61 void (*destructor) (struct abstract_po_reader_ty *pop);
63 /* This method is invoked before the parse, but after the file is
64 opened by the lexer. */
65 void (*parse_brief) (struct abstract_po_reader_ty *pop);
67 /* This method is invoked after the parse, but before the file is
68 closed by the lexer. The intention is to make consistency checks
69 against the file here, and emit the errors through the lex_error*
70 functions. */
71 void (*parse_debrief) (struct abstract_po_reader_ty *pop);
73 /* what to do with a domain directive */
74 void (*directive_domain) (struct abstract_po_reader_ty *pop, char *name);
76 /* what to do with a message directive */
77 void (*directive_message) (struct abstract_po_reader_ty *pop,
78 char *msgid, lex_pos_ty *msgid_pos,
79 char *msgid_plural,
80 char *msgstr, size_t msgstr_len,
81 lex_pos_ty *msgstr_pos,
82 bool force_fuzzy, bool obsolete);
84 /* What to do with a plain-vanilla comment - the expectation is that
85 they will be accumulated, and added to the next message
86 definition seen. Or completely ignored. */
87 void (*comment) (struct abstract_po_reader_ty *pop, const char *s);
89 /* What to do with a comment that starts with a dot (i.e. extracted
90 by xgettext) - the expectation is that they will be accumulated,
91 and added to the next message definition seen. Or completely
92 ignored. */
93 void (*comment_dot) (struct abstract_po_reader_ty *pop, const char *s);
95 /* What to do with a file position seen in a comment (i.e. a message
96 location comment extracted by xgettext) - the expectation is that
97 they will be accumulated, and added to the next message
98 definition seen. Or completely ignored. */
99 void (*comment_filepos) (struct abstract_po_reader_ty *pop,
100 const char *s, size_t line);
102 /* What to do with a comment that starts with a ',' or '!' - this is a
103 special comment. One of the possible uses is to indicate a
104 inexact translation. */
105 void (*comment_special) (struct abstract_po_reader_ty *pop, const char *s);
109 /* This next structure defines the base class passed to the methods.
110 Derived methods will often need to cast their first argument before
111 using it (this corresponds to the implicit ``this'' argument in C++).
113 When declaring derived classes, use the ABSTRACT_PO_READER_TY define
114 at the start of the structure, to declare inherited instance variables,
115 etc. */
117 #define ABSTRACT_PO_READER_TY \
118 abstract_po_reader_class_ty *methods;
120 typedef struct abstract_po_reader_ty abstract_po_reader_ty;
121 struct abstract_po_reader_ty
123 ABSTRACT_PO_READER_TY
127 /* Allocate a fresh abstract_po_reader_ty (or derived class) instance and
128 call its constructor. */
129 extern abstract_po_reader_ty *
130 po_reader_alloc (abstract_po_reader_class_ty *method_table);
132 /* Kinds of PO file input syntaxes. */
133 enum input_syntax_ty
135 syntax_po,
136 syntax_properties,
137 syntax_stringtable
139 typedef enum input_syntax_ty input_syntax_ty;
141 /* Read a PO file from a stream, and dispatch to the various
142 abstract_po_reader_class_ty methods. */
143 extern void
144 po_scan (abstract_po_reader_ty *pop, FILE *fp,
145 const char *real_filename, const char *logical_filename,
146 input_syntax_ty syntax);
148 /* Call the destructor and deallocate a abstract_po_reader_ty (or derived
149 class) instance. */
150 extern void
151 po_reader_free (abstract_po_reader_ty *pop);
154 /* Callbacks used by po-gram.y or po-lex.c, indirectly from po_scan. */
155 extern void po_callback_domain (char *name);
156 extern void po_callback_message (char *msgid, lex_pos_ty *msgid_pos,
157 char *msgid_plural,
158 char *msgstr, size_t msgstr_len,
159 lex_pos_ty *msgstr_pos,
160 bool force_fuzzy, bool obsolete);
161 extern void po_callback_comment (const char *s);
162 extern void po_callback_comment_dot (const char *s);
163 extern void po_callback_comment_filepos (const char *s, size_t line);
164 extern void po_callback_comment_special (const char *s);
165 extern void po_callback_comment_dispatcher (const char *s);
167 /* Parse a special comment and put the result in *fuzzyp, formatp, *wrapp. */
168 extern void po_parse_comment_special (const char *s, bool *fuzzyp,
169 enum is_format formatp[NFORMATS],
170 enum is_wrap *wrapp);
173 #ifdef __cplusplus
175 #endif
178 #endif /* _READ_PO_ABSTRACT_H */