~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/catalog/tag.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of KDevelop
2
 
    Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
3
 
 
4
 
    This library is free software; you can redistribute it and/or
5
 
    modify it under the terms of the GNU Library General Public
6
 
    License as published by the Free Software Foundation; either
7
 
    version 2 of the License, or (at your option) any later version.
8
 
 
9
 
    This library is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
    Library General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU Library General Public License
15
 
    along with this library; see the file COPYING.LIB.  If not, write to
16
 
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
    Boston, MA 02111-1307, USA.
18
 
*/
19
 
 
20
 
#include "tag.h"
21
 
#include <qdatastream.h>
22
 
 
23
 
Tag::Tag()
24
 
{
25
 
    data = new TagData();
26
 
    data->kind = 0;
27
 
    data->flags = 0;
28
 
    data->startLine = 0;
29
 
    data->startColumn = 0;
30
 
    data->endLine = 0;
31
 
    data->endColumn = 0;
32
 
}
33
 
 
34
 
Tag::Tag( const Tag& source )
35
 
{
36
 
    data = source.data;
37
 
    data->ref();
38
 
}
39
 
 
40
 
Tag::~Tag()
41
 
{
42
 
    if( data->deref() ){
43
 
        delete( data );
44
 
        data = 0;
45
 
    }
46
 
}
47
 
 
48
 
void Tag::detach()
49
 
{
50
 
    if( data->count != 1 )
51
 
        *this = copy();
52
 
}
53
 
 
54
 
Tag Tag::copy()
55
 
{
56
 
    Tag t;
57
 
    
58
 
    t.data->id = data->id;
59
 
    t.data->kind = data->kind;
60
 
    t.data->flags = data->flags;
61
 
    t.data->name = data->name;
62
 
    t.data->scope = data->scope;
63
 
    t.data->fileName = data->fileName;
64
 
    t.data->startLine = data->startLine;
65
 
    t.data->startColumn = data->startColumn;
66
 
    t.data->endLine = data->endLine;
67
 
    t.data->endColumn = data->endColumn;
68
 
    t.data->attributes = data->attributes;
69
 
    
70
 
    return t;
71
 
}
72
 
 
73
 
Tag& Tag::operator = ( const Tag& source )
74
 
{
75
 
    source.data->ref();
76
 
    if ( data->deref() ){
77
 
        delete data;
78
 
    }
79
 
    data = source.data;
80
 
    
81
 
    return( *this );
82
 
}
83
 
 
84
 
void Tag::load( QDataStream& stream )
85
 
{
86
 
    stream
87
 
        >> data->id
88
 
        >> data->kind
89
 
        >> data->flags
90
 
        >> data->name
91
 
        >> data->scope
92
 
        >> data->fileName
93
 
        >> data->startLine
94
 
        >> data->startColumn
95
 
        >> data->endLine
96
 
        >> data->endColumn
97
 
        >> data->attributes;
98
 
}
99
 
 
100
 
void Tag::store( QDataStream& stream ) const
101
 
{
102
 
    stream
103
 
        << data->id
104
 
        << data->kind
105
 
        << data->flags
106
 
        << data->name
107
 
        << data->scope
108
 
        << data->fileName
109
 
        << data->startLine
110
 
        << data->startColumn
111
 
        << data->endLine
112
 
        << data->endColumn
113
 
        << data->attributes;
114
 
}
115
 
 
116
 
QDataStream& operator << ( QDataStream& s, const Tag& t)
117
 
{
118
 
  t.store( s );
119
 
  return s;
120
 
}
121
 
 
122
 
QDataStream& operator >> ( QDataStream& s, Tag& t )
123
 
{
124
 
  t.load( s );
125
 
  return s;
126
 
}
127