Source Code (Use browser search to find items of interest.)

Class Index

kdevelop'CParsedAttribute (./kdevelop/kdevelop/classparser/ParsedAttribute.h:9)

class CParsedAttribute : public CParsedItem, public CParsedClassItem
{
public: // Constructor && Destructor

  CParsedAttribute();
  ~CParsedAttribute();

public: // Public attributes

  /** The attributes' type. */
  QString type;

  /** Is this attribute defined in the .h file? */
  bool isInHFile;

  /** Is this a static attribute */
  bool isStatic;

  /** Is this a const attribute */
  bool isConst;

public: // Public methods to set attribute values

  /** Set the type. */
  void setType( const char *aType );

  /** Set if it is defined in the .h file. */
  void setIsInHFile( bool aState = true );

  /** Set the attributes' static status */
  void setIsStatic( bool aState = true );

  /** Set the attributes' const status */
  void setIsConst( bool aState = true );

public: // Implementation of virtual methods

  /** Make this object a copy of the supplied object. 
   * @param anAttribute Attribute to copy. */
  virtual void copy( CParsedAttribute *anAttribute );

  /** Return the attributes code for the headerfile. */
  virtual void asHeaderCode( QString &str );

  /** Return the object as a string(for tooltips etc) */
  virtual const char *asString( QString &str );

  /** Output this object to stdout */
  virtual void out();

  /** Return a string made for persistant storage. */
  virtual const char *asPersistantString( QString &str );

  /** Initialize the object from a persistant string. */
  virtual int fromPersistantString( const char * /*str*/, int /*startPos*/ ) {return 0;}

public: // Public queries

  /** Is the supplied attribute equal to this one(regarding type and name */
  bool isEqual( CParsedAttribute &attr );
};

kdevelop'CParsedAttribute::CParsedAttribute() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:51)

CParsedAttribute::CParsedAttribute()
{
  setItemType( PIT_ATTRIBUTE );
  isConst = false;
  isStatic = false;
  isInHFile = true;
}

/*----------------------------- CParsedAttribute::~CParsedAttribute()
 * ~CParsedAttribute()
 *   Destructor.
 *
 * Parameters:
 *   -
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::~CParsedAttribute() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:68)

CParsedAttribute::~CParsedAttribute()
{
}

/*********************************************************************
 *                                                                   *
 *                    METHODS TO SET ATTRIBUTE VALUES                *
 *                                                                   *
 ********************************************************************/

/*--------------------------------------- CParsedAttribute::setType()
 * setType()
 *   Set the name of the class.
 *
 * Parameters:
 *   aName            The new name.
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::setType() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:88)

void CParsedAttribute::setType( const char *aType )
{
  assert( aType != NULL );

  type = aType;
  type = type.stripWhiteSpace();
}

/*---------------------------------- CParsedAttribute::setIsInHFile()
 * setIsInHFile()
 *   Set the name of the class.
 *
 * Parameters:
 *   aName            The new name.
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::setIsInHFile() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:106)

void CParsedAttribute::setIsInHFile( bool aState )
{
  isInHFile = aState;
}

/*---------------------------------- CParsedAttribute::setIsStatic()
 * setIsStatic()
 *   Set the attributes static status.
 *
 * Parameters:
 *   aState           Is the attribute static?
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::setIsStatic() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:121)

void CParsedAttribute::setIsStatic( bool aState )
{
  isStatic = aState;
}

/*------------------------------------- CParsedAttribute::setIsConst()
 * setIsConst()
 *   Set the attributes const status.
 *
 * Parameters:
 *   aState           Is the attribute const?
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::setIsConst() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:136)

void CParsedAttribute::setIsConst( bool aState )
{
  isConst = aState;
}

/*********************************************************************
 *                                                                   *
 *                           PUBLIC METHODS                          *
 *                                                                   *
 ********************************************************************/

/*------------------------------------------- CParsedAttribute::copy()
 * copy()
 *   Make this object a copy of the supplied object. 
 *
 * Parameters:
 *   anAttribute      Attribute to copy.
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::copy() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:157)

void CParsedAttribute::copy( CParsedAttribute *anAttribute )
{
  CParsedItem::copy( anAttribute );

  setType( anAttribute->type );
  setIsStatic( anAttribute->isStatic );
  setIsConst( anAttribute->isConst );
}

/*---------------------------------- CParsedAttribute::asHeaderCode()
 * asHeaderCode()
 *   Return the attributes code for the headerfile.
 *
 * Parameters:
 *   str              String to store the result in.
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::asHeaderCode() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:176)

void CParsedAttribute::asHeaderCode( QString &str )
{
  str = "  " + comment + "\n  ";

  if( isConst )
    str += "const ";

  if( isStatic )
    str += "static ";

  str += type + " " + name + ";\n";
}

/*-------------------------------------- CParsedAttribute::asString()
 * asString()
 *   Return the object as a string(for tooltips etc).
 *
 * Parameters:
 *   str              String to store the result in.
 *
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::asString() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:199)

const char * CParsedAttribute::asString( QString &str )
{
  str.sprintf( "%s %s", type.data(), name.data() );

  return str;
}

/*------------------------------------------- CParsedAttribute::out()
 * out()
 *   Output this object to stdout.
 *
 * Parameters:
 *   -
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::out() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:215)

void CParsedAttribute::out()
{
  char buf[10];

  if( !comment.isEmpty() )
    cout << "    " << comment << "\n";

  cout << "    ";

  switch( exportScope )
  {
    case PIE_PUBLIC:
      cout << "public ";
      break;
    case PIE_PROTECTED:
      cout << "protected ";
      break;
    case PIE_PRIVATE:
      cout << "private ";
      break;
    case PIE_GLOBAL:
      cout << "";
      break;
  }

  cout << ( type.isEmpty() ? " " : type.data() ) << " " << name;
  sprintf( buf, "%d", declaredOnLine );
  cout << " @ line " << buf << " - ";
  sprintf( buf, "%d", declarationEndsOnLine );
  cout << buf << "\n";
}

/*********************************************************************
 *                                                                   *
 *                           PUBLIC QUERIES                          *
 *                                                                   *
 ********************************************************************/

/*--------------------------------------- CParsedAttribute::isEqual()
 * isEqual()
 *   Is the supplied attribute equal to this one(regarding type and 
 *   name)?
 *
 * Parameters:
 *   attr           Attribute to compare.
 *
 * Returns:
 *   bool           Are they equal?
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::isEqual() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:264)

bool CParsedAttribute::isEqual( CParsedAttribute &attr )
{
  return (name == attr.name && type == attr.type );
}

/*--------------------------------- CParsedAttribute::asPersistantString()
 * asPersistantString()
 *   Return a string made for persistant storage.
 *
 * Parameters:
 *   -
 * Returns:
 *   -
 *-----------------------------------------------------------------*/

kdevelop'CParsedAttribute::asPersistantString() (./kdevelop/kdevelop/classparser/ParsedAttribute.cc:278)

const char *CParsedAttribute::asPersistantString( QString &dataStr )
{
  QString intStr;

  dataStr = "";

  dataStr += name + "\n";
  dataStr += type + "\n";
  dataStr += definedInFile + "\n";
  dataStr += declaredInClass + "\n";
  intStr.sprintf( "%d", definedOnLine );
  dataStr += intStr + "\n";
  dataStr += ( isInHFile ? "true" : "false" );
  dataStr += "\n";
  dataStr += ( isStatic ? "true" : "false" );
  dataStr += "\n";
  dataStr += ( isConst ? "true" : "false" );
  dataStr += "\n";
  intStr.sprintf( "%d", exportScope );
  dataStr += intStr + "\n";
  dataStr += comment.find( "\n", false ) + "\n";
  dataStr += comment +"\n";

  return dataStr;
}