Changing BroDocObj wrapper class to wrap ID instead of BroObj.

This commit is contained in:
Jon Siwek 2011-03-09 15:10:05 -06:00
parent 1c962cbb89
commit 1310f2387c
2 changed files with 17 additions and 25 deletions

View file

@ -1,15 +1,12 @@
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <list> #include <list>
#include "Obj.h" #include "ID.h"
#include "BroDocObj.h" #include "BroDocObj.h"
BroDocObj::BroDocObj(const BroObj* obj, BroDocObj::BroDocObj(const ID* id, std::list<std::string>*& reST)
std::list<std::string>*& reST,
bool exported)
{ {
broObj = obj; broID = id;
isExported = exported;
reST_doc_strings = reST; reST_doc_strings = reST;
reST = 0; reST = 0;
} }
@ -30,6 +27,6 @@ void BroDocObj::WriteReST(FILE* file) const
} }
ODesc desc; ODesc desc;
broObj->Describe(&desc); broID->DescribeExtended(&desc);
fprintf(file, "%s\n", desc.Description()); fprintf(file, "%s\n", desc.Description());
} }

View file

@ -5,19 +5,18 @@
#include <string> #include <string>
#include <list> #include <list>
#include "Obj.h" #include "ID.h"
class BroDocObj { class BroDocObj {
public: public:
/** /**
* BroDocObj constructor * BroDocObj constructor
* @param obj a pointer to a BroObj that is to be documented * @param id a pointer to an identifier that is to be documented
* @param reST a reference to a pointer of a list of strings that * @param reST a reference to a pointer of a list of strings that
represent the reST documentation for the BroObj. The pointer represent the reST documentation for the ID. The pointer
will be set to 0 after this constructor finishes. will be set to 0 after this constructor finishes.
* @param exported whether the BroObj is declared in an export section
*/ */
BroDocObj(const BroObj* obj, std::list<std::string>*& reST, bool exported); BroDocObj(const ID* id, std::list<std::string>*& reST);
/** /**
* BroDocObj destructor * BroDocObj destructor
@ -36,35 +35,31 @@ public:
* the reST as written into new reST before being written out. * the reST as written into new reST before being written out.
* This allows for additional custom markup or macros when writing * This allows for additional custom markup or macros when writing
* pure reST might be inconvenient. * pure reST might be inconvenient.
* 2) a reST friendly description of the BroObj * 2) a reST friendly description of the ID
* Could be implemented similar to the virtual BroObj::Describe(ODesc) * Could be implemented similar to the ID::DescribeExtended(ODesc)
* E.g. all subclasses will now need to implement a reSTDescribe(ODesc) * expect with new directives/roles that we'll later teach to Sphinx
* so that they can describe themselves in terms of the custom reST * via a "bro domain".
* directives/roles that we'll later teach to Sphinx via a "bro domain".
* ID's should be able to implement the reSTDescribe(ODesc) function
* such that their namespace and attributes are output as well.
* @param The (already opened) file to write the reST to. * @param The (already opened) file to write the reST to.
*/ */
void WriteReST(FILE* file) const; void WriteReST(FILE* file) const;
/** /**
* Check whether this documentation is part of the public API * Check whether this documentation is part of the public API
* (The BroObj declaration was while in an export section). * (The declaration was while in an export section).
* @return true if the BroObj was declared in an export section, else false * @return true if the ID was declared in an export section, else false
*/ */
bool IsPublicAPI() const { return isExported; } bool IsPublicAPI() const { return broID->IsExport(); }
/** /**
* Return whether this object has documentation (## comments) * Return whether this object has documentation (## comments)
* @return true if the BroObj has comments associated with it * @return true if the ID has comments associated with it
*/ */
bool HasDocumentation() const { return reST_doc_strings && bool HasDocumentation() const { return reST_doc_strings &&
reST_doc_strings->size() > 0; } reST_doc_strings->size() > 0; }
protected: protected:
std::list<std::string>* reST_doc_strings; std::list<std::string>* reST_doc_strings;
const BroObj* broObj; const ID* broID;
bool isExported;
private: private:
}; };