xref: /trunk/main/sw/inc/poolfmt.awk (revision e76eebc6)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22#
23# Dieses awk-script generiert ein cxx-file, das alle PoolIds der Vorlage dumpt.
24# wird fuer den HelpPI gebraucht.
25# Aufruf:  awk -f poolid.awk poolfmt.hxx > poolid.cxx
26#          cl poolid.cxx
27#          poolid.exe > ???.hrc
28#
29
30function Header() {
31    print "// This is an outputfile of an awk-script: $Workfile:   poolfmt.awk  $"
32    print "#include <solar.h> "
33    print
34    print  "#include <stdio.h>"
35    print  "#include <stdlib.h>"
36    print
37    print  "#pragma hdrstop"
38    print
39    print "#include <iostream.hxx> "
40    print "#include \"poolfmt.hxx\""
41    print
42}
43
44function Main() {
45	print
46    print  "void main( int , char *[] ) {"
47    sStr = "#define"
48    print  "    int nSize = (sizeof(ppPoolIds) / sizeof(PoolFmtIds)) - 1;"
49    print  "    for( int n = 0; n < nSize; n++ )"
50    print  "        printf( \"" sStr " %s\\t%8d\\n\", ppPoolIds[ n ].pStr, ppPoolIds[ n ].nId );"
51    print  "}"
52}
53
54function TableHead() {
55	print
56    print "struct PoolFmtIds { int nId; const char* pStr; };"
57    print "static PoolFmtIds ppPoolIds[] = {"
58}
59
60function TableTail() {
61    print  " 0, \"\" };"
62    print
63}
64
65BEGIN {
66    Header();
67    TableHead();
68}
69
70/^[ \t]*RES_/ && !index( $1, "_BEGIN" ) && !index( $1, "_END" ) && !index( $1, "_POOL_" ) {
71    sStr = $1;
72	split( $1, sStr, "," );
73    print  "    " sStr[1] ", \"" sStr[1] "\","
74}
75
76END {
77    TableTail();
78    Main();
79}
80
81