forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaceSpec.cc
More file actions
122 lines (102 loc) · 3.12 KB
/
interfaceSpec.cc
File metadata and controls
122 lines (102 loc) · 3.12 KB
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
#include "interfaceSpec.h"
Interface_spec__set::Interface_spec__set( int defaultSize ) {
_bufsize = defaultSize;
_buf = new Interface_spec_ptr[_bufsize];
_count = 0;
}
Interface_spec__set::~Interface_spec__set() {
delete[] _buf;
}
void Interface_spec__set::Check( int index ) {
Interface_spec_ptr * newbuf;
if( index >= _bufsize ) {
_bufsize = ( index + 1 ) * 2;
newbuf = new Interface_spec_ptr[_bufsize];
memmove( newbuf, _buf, _count * sizeof( Interface_spec_ptr ) );
delete[] _buf;
_buf = newbuf;
}
}
void Interface_spec__set::Insert( Interface_spec_ptr v, int index ) {
Interface_spec_ptr * spot;
index = ( index < 0 ) ? _count : index;
if( index < _count ) {
Check( _count + 1 );
spot = &_buf[index];
memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) );
} else {
Check( index );
spot = &_buf[index];
}
*spot = v;
++_count;
}
void Interface_spec__set::Append( Interface_spec_ptr v ) {
int index = _count;
Interface_spec_ptr * spot;
if( index < _count ) {
Check( _count + 1 );
spot = &_buf[index];
memmove( spot + 1, spot, ( _count - index )*sizeof( Interface_spec_ptr ) );
} else {
Check( index );
spot = &_buf[index];
}
*spot = v;
++_count;
}
void Interface_spec__set::Remove( int index ) {
if( 0 <= index && index < _count ) {
--_count;
Interface_spec_ptr * spot = &_buf[index];
memmove( spot, spot + 1, ( _count - index )*sizeof( Interface_spec_ptr ) );
}
}
int Interface_spec__set::Index( Interface_spec_ptr v ) {
for( int i = 0; i < _count; ++i ) {
if( _buf[i] == v ) {
return i;
}
}
return -1;
}
Interface_spec_ptr & Interface_spec__set::operator[]( int index ) {
Check( index );
_count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) );
return _buf[index];
}
int Interface_spec__set::Count() {
return _count;
}
void Interface_spec__set::Clear() {
_count = 0;
}
///////////////////////////////////////////////////////////////////////////////
Interface_spec::Interface_spec()
: _explicit_items( new Explicit_item_id__set ),
_implicit_items( 0 ), _all_objects( 0 ) {
}
/// not tested
Interface_spec::Interface_spec( Interface_spec & is ): Dictionary_instance() {
_explicit_items = new Explicit_item_id__set;
int count = is._explicit_items->Count();
int i;
for( i = 0; i < count; i++ ) {
( *_explicit_items )[i] =
( *( is._explicit_items ) )[i];
}
_current_schema_id = is._current_schema_id;
_foreign_schema_id = is._foreign_schema_id;
_all_objects = is._all_objects;
_implicit_items = 0;
}
Interface_spec::Interface_spec( const char * cur_sch_id,
const char * foreign_sch_id, int all_objects )
: _current_schema_id( cur_sch_id ), _explicit_items( new Explicit_item_id__set ),
_implicit_items( 0 ), _foreign_schema_id( foreign_sch_id ),
_all_objects( all_objects ) {
}
Interface_spec::~Interface_spec() {
delete _explicit_items;
delete _implicit_items;
}