Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / dtinfogen / infolib / etc / GenericId.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: GenericId.cc /main/5 1996/07/18 16:14:18 drk $ */
24
25 /* exported interfaces */
26 #include "GenericId.h"
27
28 /* imported interfaces */
29 #include "Dispatch.h"
30 #include "SGMLName.h"
31 #include "OLAF.h"
32 #include "OL-Data.h"
33 #include "Token.h"
34
35 #ifdef FISH_DEBUG
36 #include "dbug.h"
37 #endif
38
39 //-------------------------------------------------------------------------
40 GenericId::GenericId( const Token &t, 
41                       int name, 
42                       ActionType mode ):BaseData(t,mode)
43 {
44 #ifdef FISH_DEBUG
45   DBUG_PRINT("GenericId", (" name = %s", SGMLName::lookup(name)) );
46 #endif
47   giname = name;
48   f_data = NULL;
49   done   = 0;
50   f_base = -1;
51 }
52                       
53 //-------------------------------------------------------------------------
54 void
55 GenericId::markup( const Token &t )
56 {
57 #ifdef FISH_DEBUG
58   DBUG_PRINT( "GenericId", (" token t = %s",SGMLName::lookup(t.Gi()) ) );
59 #endif
60   
61   if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
62     return;
63   }
64
65   if ( f_data ) {
66     f_data->markup( t );
67   }
68     
69   if ( t.type() == START ) {
70
71     /* first time we see the GI */
72     if ( t.Gi() == giname && f_base < 0 && !done ) { 
73
74       /* fork off the OL_Data class for this GI */
75       f_data = new OL_Data ( t, OLAF::OL_data, (ActionType)ignore_status );
76       assert ( f_data != NULL );
77
78       f_base = t.level();
79         
80     }
81   }
82   else if ( t.type() == END ) {
83
84     if ( f_base == t.level() && !done ) {
85
86       if ( data_complete = f_data->DataIsComplete() ) {
87         ValueBuffer.writeStr( f_data->content() );
88       }
89
90       delete f_data; f_data = NULL;
91
92       done = 1;
93         
94     }
95   }
96     
97 }
98
99
100 //-------------------------------------------------------------------------
101 void
102 GenericId::data( const char *str, size_t sz )
103 {
104   if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
105     return;
106   }
107
108   if ( f_base > 0 ) {
109     if ( f_data ) {
110       f_data->data( str, sz );
111     }
112   }
113 }
114   
115
116
117