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 #include <precomp.h>
23 #include <adoc/a_rdocu.hxx>
24 
25 
26 // NOT FULLY DECLARED SERVICES
27 #include <adoc/docu_pe.hxx>
28 #include <adoc/adoc_tok.hxx>
29 #include <ary/doc/d_oldcppdocu.hxx>
30 #include <doc_deal.hxx>
31 
32 
33 
34 namespace adoc
35 {
36 
37 
DocuExplorer()38 DocuExplorer::DocuExplorer()
39 	:	pDocuDistributor(0),
40 		pPE(new Adoc_PE),
41 		bIsPassedFirstDocu(false)
42 {
43 }
44 
~DocuExplorer()45 DocuExplorer::~DocuExplorer()
46 {
47 }
48 
49 void
StartNewFile(DocuDealer & o_rDocuDistributor)50 DocuExplorer::StartNewFile( DocuDealer & o_rDocuDistributor )
51 {
52     pDocuDistributor = &o_rDocuDistributor;
53 	bIsPassedFirstDocu = false;
54 }
55 
56 
57 void
Process_Token(DYN adoc::Token & let_drToken)58 DocuExplorer::Process_Token( DYN adoc::Token & let_drToken )
59 {
60     csv_assert(pDocuDistributor != 0);
61 
62 	let_drToken.Trigger(*pPE);
63 	if ( pPE->IsComplete() )
64 	{
65         ary::doc::OldCppDocu *
66             pDocu = pPE->ReleaseJustParsedDocu();
67         if ( pDocu != 0 )
68         {
69     		if (bIsPassedFirstDocu)
70                 pDocuDistributor->TakeDocu( *pDocu );
71 		    else
72     		{
73 	    		delete pDocu;
74 		    	bIsPassedFirstDocu = true;
75     		}
76         }
77 	}
78 
79 	delete &let_drToken;
80 }
81 
82 
83 }   // namespace adoc
84 
85