LibreOffice Module idl (master) 1
bastype.cxx
Go to the documentation of this file.
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
21#include <bastype.hxx>
22#include <lex.hxx>
23#include <hash.hxx>
24#include <database.hxx>
25
26bool SvBOOL::ReadSvIdl( SvStringHashEntry const * pName, SvTokenStream & rInStm )
27{
28 sal_uInt32 nTokPos = rInStm.Tell();
29 SvToken& rTok = rInStm.GetToken_Next();
30
31 if( rTok.Is( pName ) )
32 {
33 if( rInStm.ReadIf( '=' ) )
34 {
35 rTok = rInStm.GetToken();
36 if( !rTok.IsBool() )
37 throw SvParseException(rInStm, "xxx");
38 *this = rTok.GetBool();
39 rInStm.GetToken_Next();
40 }
41 else
42 *this = true; //default action set to TRUE
43 return true;
44 }
45 rInStm.Seek( nTokPos );
46 return false;
47}
48
50{
51 sal_uInt32 nTokPos = rInStm.Tell();
52 SvToken& rTok = rInStm.GetToken_Next();
53
54 if( rTok.Is( pName ) )
55 {
56 bool bOk = true;
57 bool bBracket = rInStm.ReadIf( '(' );
58 if( bBracket || rInStm.ReadIf( '=' ) )
59 {
60 rTok = rInStm.GetToken();
61 if( rTok.IsIdentifier() )
62 {
63 setString(rTok.GetString());
64 rInStm.GetToken_Next();
65 }
66 if( bOk && bBracket )
67 bOk = rInStm.ReadIf( ')' );
68 }
69 if( bOk )
70 return;
71 }
72 rInStm.Seek( nTokPos );
73}
74
76 SvTokenStream & rInStm )
77{
78 sal_uInt32 nTokPos = rInStm.Tell();
79 SvToken& rTok = rInStm.GetToken_Next();
80
81 if( rTok.IsIdentifier() )
82 {
83 sal_uInt32 n;
84 if( !rBase.FindId( rTok.GetString(), &n ) )
85 rBase.SetAndWriteError( rInStm, "no value for identifier <" + getString() + "> " );
86 setString(rTok.GetString());
87 nValue = n;
88 return;
89 }
90 rInStm.Seek( nTokPos );
91}
92
93bool ReadStringSvIdl( SvStringHashEntry const * pName, SvTokenStream & rInStm, OString& aRetString )
94{
95 sal_uInt32 nTokPos = rInStm.Tell();
96 SvToken& rTok = rInStm.GetToken_Next();
97
98 if( rTok.Is( pName ) )
99 {
100 bool bOk = true;
101 bool bBracket = rInStm.ReadIf( '(' );
102 if( bBracket || rInStm.ReadIf( '=' ) )
103 {
104 rTok = rInStm.GetToken();
105 if( rTok.IsString() )
106 {
107 aRetString = rTok.GetString();
108 rInStm.GetToken_Next();
109 }
110 if( bOk && bBracket )
111 bOk = rInStm.ReadIf( ')' );
112 }
113 if( bOk )
114 return true;
115 }
116 rInStm.Seek( nTokPos );
117 return false;
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
bool ReadStringSvIdl(SvStringHashEntry const *pName, SvTokenStream &rInStm, OString &aRetString)
Definition: bastype.cxx:93
bool ReadSvIdl(SvStringHashEntry const *pName, SvTokenStream &rInStm)
Definition: bastype.cxx:26
void ReadSvIdl(SvStringHashEntry const *pName, SvTokenStream &rInStm)
Definition: bastype.cxx:49
void setString(const OString &rStr)
Definition: bastype.hxx:56
sal_uInt32 nValue
Definition: bastype.hxx:51
const OString & getString() const
Definition: bastype.hxx:57
void SetAndWriteError(SvTokenStream &rInStm, const OString &rError)
Definition: database.cxx:101
bool FindId(const OString &rIdName, sal_uInt32 *pVal)
Definition: database.cxx:112
void Seek(sal_uInt32 nPos)
Definition: lex.hxx:202
SvToken & GetToken() const
Definition: lex.hxx:177
bool ReadIf(char cChar)
Definition: lex.hxx:179
SvToken & GetToken_Next()
Definition: lex.hxx:165
sal_uInt32 Tell() const
Definition: lex.hxx:200
Definition: lex.hxx:36
bool IsBool() const
Definition: lex.hxx:65
bool IsString() const
Definition: lex.hxx:64
bool GetBool() const
Definition: lex.hxx:83
bool Is(SvStringHashEntry const *pEntry) const
Definition: lex.hxx:88
bool IsIdentifier() const
Definition: lex.hxx:68
const OString & GetString() const
Definition: lex.hxx:76
sal_Int64 n