Fix for UBSan build
[platform/upstream/doxygen.git] / src / arguments.cpp
1 #include "arguments.h"
2 #include "marshal.h"
3 #include <assert.h>
4
5 /*! the argument list is documented if one of its
6  *  arguments is documented 
7  */
8 bool ArgumentList::hasDocumentation() const
9 {
10   bool hasDocs=FALSE;
11   ArgumentListIterator ali(*this);
12   Argument *a;
13   for (ali.toFirst();!hasDocs && (a=ali.current());++ali)
14   {
15     hasDocs = a->hasDocumentation(); 
16   }
17   return hasDocs;
18 }
19
20 ArgumentList *ArgumentList::deepCopy() const
21 {
22   ArgumentList *argList = new ArgumentList;
23   argList->setAutoDelete(TRUE);
24
25   QListIterator<Argument> ali(*this);
26   Argument *a;
27   for (;(a=ali.current());++ali)
28   {
29     argList->append(new Argument(*a));
30   }
31   argList->constSpecifier     = constSpecifier;
32   argList->volatileSpecifier  = volatileSpecifier;
33   argList->pureSpecifier      = pureSpecifier;
34   argList->trailingReturnType = trailingReturnType;
35
36   return argList;
37 }
38
39 ArgumentList *ArgumentList::unmarshal(StorageIntf *s)
40 {
41   uint i;
42   uint count = unmarshalUInt(s);
43   if (count==NULL_LIST) return 0; // null list
44   ArgumentList *result = new ArgumentList;
45   assert(count<1000000);
46   //printf("unmarshalArgumentList: %d\n",count);
47   for (i=0;i<count;i++)
48   {
49     Argument *a = new Argument;
50     a->attrib  = unmarshalQCString(s);
51     a->type    = unmarshalQCString(s);
52     a->canType = unmarshalQCString(s);
53     a->name    = unmarshalQCString(s);
54     a->array   = unmarshalQCString(s);
55     a->defval  = unmarshalQCString(s);
56     a->docs    = unmarshalQCString(s);
57     result->append(a);
58   }
59   result->constSpecifier     = unmarshalBool(s);
60   result->volatileSpecifier  = unmarshalBool(s);
61   result->pureSpecifier      = unmarshalBool(s);
62   result->trailingReturnType = unmarshalQCString(s);
63   return result;
64 }
65
66 void ArgumentList::marshal(StorageIntf *s,ArgumentList *argList)
67 {
68   if (argList==0)
69   {
70     marshalUInt(s,NULL_LIST); // null pointer representation
71   }
72   else
73   {
74     marshalUInt(s,argList->count());
75     if (argList->count()>0)
76     {
77       ArgumentListIterator ali(*argList);
78       Argument *a;
79       for (ali.toFirst();(a=ali.current());++ali)
80       {
81         marshalQCString(s,a->attrib);    
82         marshalQCString(s,a->type);    
83         marshalQCString(s,a->canType);    
84         marshalQCString(s,a->name);    
85         marshalQCString(s,a->array);    
86         marshalQCString(s,a->defval);    
87         marshalQCString(s,a->docs);    
88       }
89     }
90     marshalBool(s,argList->constSpecifier);
91     marshalBool(s,argList->volatileSpecifier);
92     marshalBool(s,argList->pureSpecifier);
93     marshalQCString(s,argList->trailingReturnType);
94   }
95 }
96