paramhandler.cpp 3.83 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2 3 4 5
/******************************************************************************
 *
 * $Id$
 *
 *
6
 * Copyright (C) 1997-2013 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
7 8 9 10 11 12 13 14 15
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
16 17
#include "paramhandler.h"
#include "memberhandler.h"
18
#include "linkedtexthandler.h"
19
#include "debug.h"
20
#include "dochandler.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
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
TemplateParamListHandler::TemplateParamListHandler(IBaseHandler *parent) : m_parent(parent)
{
  addStartHandler("param",this,&TemplateParamListHandler::startParam);

  addEndHandler("templateparamlist",this,&TemplateParamListHandler::endTemplateParamList);
}

void TemplateParamListHandler::startParam(const QXmlAttributes& attrib)
{
  ParamHandler *ph = new ParamHandler(this);
  ph->startParam(attrib);
  m_templateParams.append(ph);
}

void TemplateParamListHandler::endParam()
{
}

void TemplateParamListHandler::startTemplateParamList(const QXmlAttributes& /*attrib*/)
{
  m_parent->setDelegate(this);
  debug(2,"templateparamlist\n");
}

void TemplateParamListHandler::endTemplateParamList()
{
  m_parent->setDelegate(0);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

53
ParamHandler::ParamHandler(IBaseHandler *parent) : m_brief(0), m_parent(parent)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
54 55 56
{
  addEndHandler("param",this,&ParamHandler::endParam);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
57
  addStartHandler("type",this,&ParamHandler::startType);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
58 59 60 61 62 63 64 65 66 67

  addStartHandler("declname");
  addEndHandler("declname",this,&ParamHandler::endDeclName);

  addStartHandler("defname");
  addEndHandler("defname",this,&ParamHandler::endDefName);

  addStartHandler("array");
  addEndHandler("array",this,&ParamHandler::endArray);

68 69
  addStartHandler("attribute");
  addEndHandler("attribute",this,&ParamHandler::endAttrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
70

71 72
  addStartHandler("briefdescription",this,&ParamHandler::startBriefDesc);
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
73 74 75
  addStartHandler("defval",this,&ParamHandler::startDefVal);

  m_linkedTextHandler = 0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
76 77 78 79
}

ParamHandler::~ParamHandler()
{
80
  delete m_brief;
81
  delete m_linkedTextHandler;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
82 83 84 85 86
}

void ParamHandler::startParam(const QXmlAttributes& /*attrib*/)
{
  m_parent->setDelegate(this);
87
  debug(2,"param\n");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
88 89 90 91 92 93 94
}

void ParamHandler::endParam()
{
  m_parent->setDelegate(0);
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
95
void ParamHandler::startType(const QXmlAttributes& /*attrib*/)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
96
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
97 98 99
  delete m_linkedTextHandler;
  m_linkedTextHandler = new LinkedTextHandler(this,m_type);
  m_linkedTextHandler->start("type");
100
  debug(2,"param type\n");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
101 102 103 104 105
}

void ParamHandler::endDeclName()
{
  m_declName = m_curString.stripWhiteSpace();
106
  debug(2,"member declName=`%s'\n",m_declName.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
107 108 109 110 111
}

void ParamHandler::endDefName()
{
  m_defName = m_curString.stripWhiteSpace();
112
  debug(2,"member defName=`%s'\n",m_defName.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
113 114 115 116 117
}

void ParamHandler::endAttrib()
{
  m_attrib = m_curString.stripWhiteSpace();
118
  debug(2,"member attrib=`%s'\n",m_attrib.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
119 120 121 122 123
}

void ParamHandler::endArray()
{
  m_array = m_curString.stripWhiteSpace();
124
  debug(2,"member array=`%s'\n",m_array.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
125 126
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
127
void ParamHandler::startDefVal(const QXmlAttributes& /*attrib*/)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
128
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
129 130
  delete m_linkedTextHandler;
  m_linkedTextHandler = new LinkedTextHandler(this,m_defVal);
131 132
  m_linkedTextHandler->start("defval");
  debug(2,"member defVal\n");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
133 134
}

135 136 137 138 139 140 141
void ParamHandler::startBriefDesc(const QXmlAttributes& attrib)
{
  DocHandler *docHandler = new DocHandler(this);
  docHandler->startDoc(attrib);
  m_brief = docHandler;
}

142 143 144 145 146 147 148 149 150
ILinkedTextIterator *ParamHandler::type() const 
{ 
  return new LinkedTextIterator(m_type); 
}

ILinkedTextIterator *ParamHandler::defaultValue() const 
{ 
  return new LinkedTextIterator(m_defVal); 
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
151

152 153 154 155 156 157
IDocRoot *ParamHandler::briefDescription() const
{ 
  return m_brief; 
}
    

Dimitri van Heesch's avatar
Dimitri van Heesch committed
158