Click here to Skip to main content
15,884,628 members
Articles / Desktop Programming / MFC

Be Sweet - a set of visual source code browsers

Rate me:
Please Sign up or sign in to vote.
4.85/5 (35 votes)
1 Jul 20038 min read 183.7K   4.9K   122  
A set of source code and project browsers to compliment Visual Studio.
#ifndef Tag_H
#define Tag_H

#include "CppTagModel.h"

#include <vector>
#include <string>
#include <list>

namespace CTags {

class Tag
{
private:
  mutable long mHash;
  mutable long mWeakHash;

  std::string mName;
  std::string mFile;
  std::string mCode;
  std::list<std::string> mInheritance;
  std::list<std::string> mSignature;

  CppTagType mType;

  std::string empty;
  bool mIsDeclaration;
  
  size_t mLine;
  
  std::string mScope;
  CppTagType mScopeType;

  FullQualifiedName mFQN;
  
  AccessQualifier mAccessQualifier;
  ImplementationQualifier mImplementationQualifier;


public:
  Tag(){};

  explicit Tag(std::string line);

  long hash() const;
  long weakhash() const;

	bool isBuddyOf(const Tag&) const;

  const std::string& getName() const { return getFQN().getName(); }
  const std::string& getFile() const { return mFile; }
  const std::string& getCode() const { return mCode; }
  const std::list<std::string>& getInheritance() const { return mInheritance; }

  CppTagType getType() const { return mType; }
  const std::list<std::string>& getSignature() const { return mSignature; }

  std::string getScope() const { return getFQN().getScope(); };
  CppTagType getScopeType() const { return mScopeType; };
  
  const FullQualifiedName& getFQN() const { return mFQN; }
  
  ImplementationQualifier getImplementationQualifier() const { return mImplementationQualifier; };
  AccessQualifier getAccessQualifier() const { return mAccessQualifier; };

  size_t getLine() const { return mLine; }

  bool isDeclaration() const { return mIsDeclaration; }

  std::string getReturnType() const;

  //bool operator<(const Tag &rhs) const { return hash() < rhs.hash(); };
  
private:
  std::string getMethodHash() const;

  void prepare(std::string&);
  bool setupTagType(const std::string &);
  bool setupScope(const std::string &);
  bool setupLine(const std::string&);
  bool setupImplementationQualifier(const std::string&);
  bool setupAccessQualifier(const std::string&);
  bool setupInheritance(const std::string&);
  bool setupSignature(const std::string&);

  long generateHash(bool weak) const;

};

struct isInFile : std::binary_function<std::string, Tag, bool>
{
  result_type operator() (const first_argument_type &file, const second_argument_type &tag) const
  { return tag.getFile() == file; }
};

} //namespace CTags

#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
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions