0518f39c6cf01b61d4fe4f69ec743504c479e902
[oweals/cde.git] / cde / programs / dtinfo / dtinfogen / infolib / etc / FirstOf.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: FirstOf.C /main/3 1996/08/21 15:46:47 drk $ */
24 /* exported interfaces */
25 #include "FirstOf.h"
26
27 /* imported interfaces */
28 #include "Dispatch.h"
29 #include "OLAF.h"
30 #include "ExprList.h"
31 #include "Expression.h"
32 #include "Token.h"
33 #include "OL-Data.h"
34 #include "ConcatTask.h"
35 #include "Content.h"
36 #include "AttributeData.h"
37 #include "GenericId.h"
38 #include "Literal.h"
39
40
41 //---------------------------------------------------------------------
42 FirstOf::FirstOf( const Token &t, 
43                   ExprList *el, 
44                   ActionType mode ):BaseData(t,mode)
45 {
46   f_base = t.level();
47
48   for ( OL_Expression *local_list = el->first();
49         local_list;
50         local_list = el->next(local_list) ) {
51
52     switch ( local_list->type() ) {
53
54       case CONTENT :
55         addSubTask( new Content( t,mode) );
56         break;
57       
58       case CONCAT :
59         addSubTask( new Concat ( t, 
60                                  (ExprList *) local_list->data_list(),
61                                  mode) );
62         break;
63
64       case FIRSTOF :
65         addSubTask( new FirstOf( t, 
66                                  (ExprList *)local_list->data_list(), 
67                                  mode) );
68         break;
69
70       case GENERIC_ID :
71         addSubTask( new GenericId(t, 
72                                   local_list->name(),
73                                   mode) );
74         break;
75
76       case LITERAL :
77         addSubTask( new Literal( t, 
78                                  (const char *)local_list->data_list(),
79                                  mode) );
80         break;
81
82       case REFERENCE :
83         addSubTask( new AttributeData( t, 
84                                        local_list->name(),
85                                        mode ));
86         break;
87
88       default:
89         abort();
90    }
91
92   }
93 }
94
95 //--------------------------------------------------------------------------
96 void
97 FirstOf::markup( const Token &t )
98 {
99
100   if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
101     return;
102   }
103
104   if ( f_base > 0 ) {
105
106     ComplexTask::markup( t );
107
108     if ( t.type() == END ) {
109
110       if ( t.level() == f_base ) {
111
112         data_complete = 1;
113         
114         for ( int i = 0; i < ComplexTask::used; i++ ) {
115           BaseData *task = ( BaseData *)ComplexTask::subtask(i);
116           if ( task->DataIsComplete() ) {
117             ValueBuffer.writeStr( task->content() );
118             break;
119           }
120         }
121
122         f_base = -1;
123         ComplexTask::removeAllSubTasks();
124
125       }
126     }
127   }
128 }
129     
130             
131
132
133     
134
135     
136     
137