Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ClassEncoder::attribute_info Class Reference

Base class for attributes. More...

#include <attribute_info.hpp>

Inheritance diagram for ClassEncoder::attribute_info:

Inheritance graph
[legend]
Collaboration diagram for ClassEncoder::attribute_info:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 attribute_info ()
 Default constructor.

virtual ~attribute_info ()
 Default destructor.

virtual void write (std::ofstream &stream)
 Write contents to stream.

virtual unsigned int size ()=0
 Size of this attribute.


Protected Member Functions

void setNameIndex (u2 index)
 Set the index to the name in the constant pool.


Private Attributes

u2 attribute_name_index

Detailed Description

Base class for attributes.

This class is the base class for all JVM class attributes. The JVM attributes are documented here http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817. All attributes must inherit from this class and they must all implement both the size and the write function.

Todo:
Add Valid bit for name_index set.

Definition at line 30 of file attribute_info.hpp.


Constructor & Destructor Documentation

ClassEncoder::attribute_info::attribute_info  ) 
 

Default constructor.

Empty

Definition at line 20 of file attribute_info.cpp.

ClassEncoder::attribute_info::~attribute_info  )  [virtual]
 

Default destructor.

Empty

Definition at line 28 of file attribute_info.cpp.


Member Function Documentation

void ClassEncoder::attribute_info::setNameIndex u2  index  )  [inline, protected]
 

Set the index to the name in the constant pool.

Set the name of this class.

Parameters:
index The index to the constant pool entry containing the name. All subclasses are responsible for setting the name.

Definition at line 50 of file attribute_info.hpp.

Referenced by ClassEncoder::code_attribute::code_attribute().

virtual unsigned int ClassEncoder::attribute_info::size  )  [pure virtual]
 

Size of this attribute.

All subclasses must implement this function.

Returns:
The size of the contents of the subclasses not counting the attribute_name_index and the size. (6 bytes)

Implemented in ClassEncoder::code_attribute.

Referenced by write().

void ClassEncoder::attribute_info::write std::ofstream &  stream  )  [virtual]
 

Write contents to stream.

Writes the index and the size of this attribute to the stream. Subclasses reimplementing this must take care to call this function before writing their contents to the stream in order to write the whole attribute to the stream correctly.

Reimplemented in ClassEncoder::code_attribute.

Definition at line 37 of file attribute_info.cpp.

References size(), ClassEncoder::ClassWriterBase::writeu2(), and ClassEncoder::ClassWriterBase::writeu4().


The documentation for this class was generated from the following files:
Generated on Mon Dec 1 14:26:28 2003 for Ck by doxygen 1.3.3