1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include <x_parse.hxx>
30 
31 // NOT FULLY DECLARED SERVICES
32 
33 
34 
35 X_Parser::X_Parser( E_Event				i_eEvent,
36                     const char *		i_sObject,
37                     const String &      i_sCausingFile_FullPath,
38 					uintt				i_nCausingLineNr  )
39 	:	eEvent(i_eEvent),
40 	    sObject(i_sObject),
41 	    sCausingFile_FullPath(i_sCausingFile_FullPath),
42 	    nCausingLineNr(i_nCausingLineNr)
43 {
44 }
45 
46 X_Parser::~X_Parser()
47 {
48 }
49 
50 X_Parser::E_Event
51 X_Parser::GetEvent() const
52 {
53  	return eEvent;
54 }
55 
56 void
57 X_Parser::GetInfo( std::ostream & o_rOutputMedium ) const
58 {
59     o_rOutputMedium << "Error in file "
60                     << sCausingFile_FullPath
61                     << " in line "
62                     << nCausingLineNr
63                     << ": ";
64 
65 
66 	switch (eEvent)
67     {
68 		case x_InvalidChar:
69 			o_rOutputMedium << "Unknown character '"
70 							<< sObject
71                             << "'";
72 			break;
73 		case x_UnexpectedToken:
74 			o_rOutputMedium << "Unexpected token \""
75 							<< sObject
76 							<< "\"";
77 			break;
78 		case x_UnexpectedEOF:
79 			o_rOutputMedium << "Unexpected end of file.";
80 			break;
81 		case x_UnspecifiedSyntaxError:
82 			o_rOutputMedium << "Unspecified syntax problem in file.";
83 			break;
84 		case x_Any:
85 		default:
86 			o_rOutputMedium << "Unspecified parsing exception.";
87 	}	// end switch
88     o_rOutputMedium << Endl();
89 }
90 
91 
92 std::ostream &
93 operator<<( std::ostream &                  o_rOut,
94             const autodoc::X_Parser_Ifc &   i_rException )
95 {
96     i_rException.GetInfo(o_rOut);
97  	return o_rOut;
98 }
99