Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFGRPRD_HXX
21 : #define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFGRPRD_HXX
22 :
23 : #include <sal/types.h>
24 :
25 : #include <tools/stream.hxx>
26 :
27 :
28 1 : class DXFGroupReader
29 : {
30 :
31 : public:
32 :
33 : DXFGroupReader( SvStream & rIStream );
34 :
35 : bool GetStatus() const;
36 :
37 : void SetError();
38 :
39 : sal_uInt16 Read();
40 : // Reads next group and returns the group code.
41 : // In case of an error GetStatus() returns sal_False, group code will be set
42 : // to 0 and SetS(0,"EOF") will be executed.
43 0 : bool Read(sal_uInt16 nExpectedG) { return Read() == nExpectedG; }
44 :
45 : sal_uInt16 GetG() const;
46 : // Return the last group code (the one the last Read() did return).
47 :
48 : long GetI() const;
49 : // Returns the integer value of the group which was read earlier with Read().
50 : // This read must have returned a group code for datatype Integer.
51 : // If not 0 is returend
52 :
53 : double GetF() const;
54 : // Returns the floating point value of the group which was read earlier with Read().
55 : // This read must have returned a group code for datatype Floatingpoint.
56 : // If not 0 is returend
57 :
58 : const OString& GetS() const;
59 : // Returns the string of the group which was read earlier with Read().
60 : // This read must have returned a group code for datatype String.
61 : // If not NULL is returend
62 :
63 : // The following methods can change the current values of group codes
64 : // (e.g. to set default values, before 'blindly' reading lots of groups)
65 :
66 : void SetS(); // (will be copied)
67 :
68 : private:
69 :
70 : long ReadI();
71 : double ReadF();
72 : void ReadS();
73 :
74 : SvStream & rIS;
75 : bool bStatus;
76 : sal_uInt16 nLastG;
77 : sal_uLong nGCount;
78 :
79 : sal_uLong nFileSize;
80 :
81 : OString S;
82 : union {
83 : double F;
84 : long I;
85 : };
86 : };
87 :
88 :
89 1 : inline bool DXFGroupReader::GetStatus() const
90 : {
91 1 : return bStatus;
92 : }
93 :
94 :
95 0 : inline void DXFGroupReader::SetError()
96 : {
97 0 : bStatus=false;
98 0 : }
99 :
100 400 : inline sal_uInt16 DXFGroupReader::GetG() const
101 : {
102 400 : return nLastG;
103 : }
104 :
105 0 : inline long DXFGroupReader::GetI() const
106 : {
107 0 : return I;
108 : }
109 :
110 0 : inline double DXFGroupReader::GetF() const
111 : {
112 0 : return F;
113 : }
114 :
115 58 : inline const OString& DXFGroupReader::GetS() const
116 : {
117 58 : return S;
118 : }
119 :
120 : #endif
121 :
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|