Click here to Skip to main content
15,891,864 members
Articles / Desktop Programming / MFC

Another Enum Viewer

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
22 Oct 20015 min read 83K   1.3K   19  
An article on the usage and design of another Enum Viewer
// CPPTypeBuiltin.h: definition of builtin-type class

#ifndef INCL_CPPTYPEBUILTIN_H
#define INCL_CPPTYPEBUILTIN_H

#include "CPPType.h"

///////////////////////////////////////////////////////////////////////
// CPPTypeBuiltin declaration class.  This class holds declarations of
// combinations of various builtin types (int/long/double/unsigned/etc).
///////////////////////////////////////////////////////////////////////
class CPPTypeBuiltin : public CPPType
{
public:
   CPPTypeBuiltin(
      CPPConst::TypeSpecifier typeSpecifier_
   );
   virtual ~CPPTypeBuiltin() { assertValid(); }

   // access methods
   CPPConst::TypeSpecifier GetTypeSpecifier() const { 
      assertValid(); return typeSpecifier; 
   }

   // Format the name of the type
   virtual JLStr FormatName(
      const JLStr& declName, 
      const JLStr& suffixStr,
      StrListRefI argList,
      bool forSpecialization
   ) const;

   // Format the name of the type specifiers (may be used for invalid types)
   static JLStr FormatTypeSpecifierName(CPPConst::TypeSpecifier ts);

   // Method to validate builtin types
   static bool TypeSpecifierIsValid(CPPConst::TypeSpecifier typeSpecifier);

   // Ordering of two nodes
   virtual bool LessThanNode(const CPPType& rhs) const
   {
      assertValid();
      return 
         CPPType::LessThanNode(rhs) ||
         (
            rhs.GetFlavor() == Builtin && 
            typeSpecifier < STATIC_CAST(const CPPTypeBuiltin*, &rhs)->GetTypeSpecifier()
         );
   }

private:
   // disallow copy or assignment
   CPPTypeBuiltin(const CPPTypeBuiltin&);
   void operator=(const CPPTypeBuiltin&);

   void assertValid() const { CPPType::assertValid(); assert(GetFlavor() == Builtin); }

   CPPConst::TypeSpecifier typeSpecifier;

   // Initialize the static data members if necessary
   static void InitTables();

	class CompatTableVector;
   static CompatTableVector *compatTable;

	class NameTableVector;
   static NameTableVector *nameTable;
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions