summaryrefslogtreecommitdiffstats
path: root/kode/kwsdl/schema/complextype.h
blob: 39db08b69c74347176e47db0522bb430e3614a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* 
    This file is part of KDE Schema Parser

    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
                       based on wsdlpull parser by Vivek Krishna

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
 */

#ifndef SCHEMA_COMPLEXTYPE_H
#define SCHEMA_COMPLEXTYPE_H

#include <tqstring.h>

#include "attribute.h"
#include "element.h"
#include "qualifiedname.h"
#include "xsdtype.h"

namespace Schema {

class ComplexType : public XSDType
{
  public:
    typedef TQValueList<ComplexType> List;

    typedef enum { 
      SEQ = 0, 
      CHOICE, 
      ALL 
    } Compositor;

    typedef enum {
      Restriction,
      Extension
    } Derivation;
       
    ComplexType();
    ComplexType( const TQString& );
    ~ComplexType();

    void setName( const TQString &name );
    TQString name() const;

    QualifiedName qualifiedName() const;

    void setDocumentation( const TQString &documentation );
    TQString documentation() const;

    void setType( int type );
    int type() const;

    void setContentType( int contentType );
    int contentType() const;

    void setContentModel( int model );
    int contentModel() const;

    bool isSimple() const;

    int attributeType( int index );
    TQString attributeName( int index );

    int elementType( int index );
    TQString elementName( int index );

    int numElements() const;
    int numAttributes() const;

    void setAnonymous( bool anonymous );
    bool isAnonymous() const;

    void setBaseType( int type, Derivation derivation, const XSDType *ptr );
    void setBaseTypeName( const TQString &baseTypeName );

    int baseType() const;
    int baseDerivation() const;
    TQString baseTypeName() const;

    Compositor topLevelGroup() const;
    Compositor groupType( int groupId ) const;

    const Element *element( const TQString &name );
    const Attribute *attribute( const TQString &name );
    Element *element( int id );
    Attribute *attribute( int id );

    void setElements( const Element::List &elements );
    Element::List elements() const;

    void setAttributes( const Attribute::List &attributes );
    Attribute::List attributes() const;

    void setIsArray( bool isArray );
    bool isArray() const;

    void setCompositor( Compositor type, bool open = true, int minOccurs = 1, int maxOccurs = 1 );

    void addAttribute( const TQString &name, int type_id, bool qualified = false,
                       const TQString &defaultValue = TQString(),
                       const TQString &fixedValue = TQString(),
                       bool use = false );
    void addAttributeRef( const QualifiedName &name, bool qualified, bool use );

    void addElement( const TQString &name, int type_id, int minOccurs = 1,
                     int maxOccurs = 1, bool qualified = false,
                     const TQString &defaultValue = TQString(),
                     const TQString &fixedValue = TQString(),
                     const TQString &documentation = TQString() );
    void addElementRef( const QualifiedName &name, int minOccurs, int maxOccurs );

    void matchAttributeRef( const TQString &name, Attribute &attribute );
    void matchElementRef( const TQString &name, Element &element );

    bool checkOccurrences();
    void resetCounters();

  private:
    TQString mName;
    TQString mNameSpace;
    TQString mDocumentation;
    int mType;

    Element::List mElements;
    Attribute::List mAttributes;

    int mContentModel;
    bool mMixed;
    bool mAnonymous;
    bool mIsArray;
    int mContentType;
 
    struct
    {
      int typeId;
      Derivation derivation;
      const  XSDType *type;
      TQString name;
    } mBaseType;
  
    struct CompositorStruct
    {
      CompositorStruct()
      {
      }

      CompositorStruct( Compositor _type, int min = 1, int max = 1 )
        : type( _type ), minOccurs( min ), maxOccurs( max )
      {
      }

      Compositor type;
      int minOccurs;
      int maxOccurs;
    };

    TQValueList<struct CompositorStruct> mGroups;

    Compositor mTopLevelGroup;
    int mCurrentGroup;
    int mPreviousGroup;
    bool mForwardElementRef;
    bool mForwardAttributeRef;
};

}

#endif