LibreOffice Module idl (master) 1
basobj.hxx
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#ifndef INCLUDED_IDL_INC_BASOBJ_HXX
21#define INCLUDED_IDL_INC_BASOBJ_HXX
22
23#include <tools/ref.hxx>
24#include "bastype.hxx"
25#include <vector>
26
27class SvTokenStream;
28class SvIdlDataBase;
29
30template<typename T>
31class SvRefMemberList : private std::vector<T>
32{
33private:
34 typedef typename std::vector<T> base_t;
35
36public:
37 using base_t::size;
38 using base_t::front;
39 using base_t::back;
40 using base_t::operator[];
41 using base_t::begin;
42 using base_t::end;
43 using typename base_t::iterator;
44 using typename base_t::const_iterator;
45 using base_t::rbegin;
46 using base_t::rend;
47 using typename base_t::reverse_iterator;
48 using base_t::empty;
49
51 void clear()
52 {
53 for( typename base_t::const_iterator it = base_t::begin(); it != base_t::end(); ++it )
54 {
55 T p = *it;
56 if( p )
57 p->ReleaseRef();
58 }
59 base_t::clear();
60 }
61
62 void push_back( T p )
63 {
64 base_t::push_back( p );
65 p->AddFirstRef();
66 }
67
68 void insert( typename base_t::iterator it, T p )
69 {
70 base_t::insert( it, p );
71 p->AddFirstRef();
72 }
73
74 void pop_back()
75 {
76 T p = base_t::back();
77 base_t::pop_back();
78 if( p )
79 p->ReleaseRef();
80 }
81};
82
83class SvMetaObject : public SvRefBase
84{
85 OString aName;
86
87protected:
88 bool ReadNameSvIdl( SvTokenStream & rInStm );
90 virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
91 virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase,
92 SvTokenStream & rInStm );
93public:
95
96 static void WriteTab( SvStream & rOutStm, sal_uInt16 nTab );
97 static void Back2Delimiter( SvStream & );
98 static void WriteStars( SvStream & );
99
100 void SetName( const OString& rName );
101 virtual const OString & GetName() const { return aName; }
102
103 virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
104};
105
107{
109public:
111
112 const OString & GetName() const override
113 {
114 return ( !aRef.is()
115 || !SvMetaObject::GetName().isEmpty() )
117 : aRef->GetName();
118 }
119
120 SvMetaReference * GetRef() const { return aRef.get(); }
121 void SetRef( SvMetaReference * pRef )
122 { aRef = pRef; }
123};
124
125#endif // INCLUDED_IDL_INC_BASOBJ_HXX
126
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void DoReadContextSvIdl(SvIdlDataBase &, SvTokenStream &rInStm)
Definition: basobj.cxx:92
OString aName
Definition: basobj.hxx:85
virtual void ReadContextSvIdl(SvIdlDataBase &, SvTokenStream &rInStm)
Definition: basobj.cxx:104
void SetName(const OString &rName)
Definition: basobj.cxx:66
static void WriteStars(SvStream &)
Definition: basobj.cxx:33
SvMetaObject()
Definition: basobj.cxx:62
virtual const OString & GetName() const
Definition: basobj.hxx:101
bool ReadNameSvIdl(SvTokenStream &rInStm)
Definition: basobj.cxx:71
static void WriteTab(SvStream &rOutStm, sal_uInt16 nTab)
Definition: basobj.cxx:27
virtual void ReadAttributesSvIdl(SvIdlDataBase &rBase, SvTokenStream &rInStm)
Definition: basobj.cxx:87
virtual bool ReadSvIdl(SvIdlDataBase &, SvTokenStream &rInStm)
Definition: basobj.cxx:108
static void Back2Delimiter(SvStream &)
Definition: basobj.cxx:41
void SetRef(SvMetaReference *pRef)
Definition: basobj.hxx:121
tools::SvRef< SvMetaReference > aRef
Definition: basobj.hxx:108
SvMetaReference * GetRef() const
Definition: basobj.hxx:120
const OString & GetName() const override
Definition: basobj.hxx:112
void pop_back()
Definition: basobj.hxx:74
void insert(typename base_t::iterator it, T p)
Definition: basobj.hxx:68
std::vector< T > base_t
Definition: basobj.hxx:34
void clear()
Definition: basobj.hxx:51
void push_back(T p)
Definition: basobj.hxx:62
T * get() const
bool is() const
void * p