Click here to Skip to main content
15,867,771 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.1K   4.9K   122  
A set of source code and project browsers to compliment Visual Studio.
/**
/*   Copyright (c) 2003by  Marco Welti
/*
/*   This document is  bound by the  QT Public License
/*   (http://www.trolltech.com/licenses/qpl.html).
/*   See License.txt for more information.
/*
/*
/*
/*   ALL RIGHTS RESERVED.  
/* 
/*   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
/*   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/*   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
/*   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
/*   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
/*   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
/*   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
/*   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
/*   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
/*   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
/*   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 
/***********************************************************************/

#ifndef MetaModelUtilities_H
#define MetaModelUtilities_H

#include <Model/MetaModel/MetaModel.h>
#include <Utilities/smart_ptr.h>

#include <list>
#include <map>
#include <functional>

class RootFinder
{
public:
  typedef std::map<size_t, std::list<smart_ptr<Inheritable> > > RootMap;

public:
  RootMap findRootOf(const smart_ptr<Inheritable>&);

};

struct IsRelativeOf : public std::binary_function<smart_ptr<Inheritable>, smart_ptr<Inheritable>, bool>
{  
  bool operator()(const smart_ptr<Inheritable> &r1, const smart_ptr<Inheritable> &r2) const;
  
  static bool isParentOf(const smart_ptr<Inheritable> &parent, const smart_ptr<Inheritable> &child);
  static bool isExtendorOf(const smart_ptr<Inheritable> &child, const smart_ptr<Inheritable> &parent);
};

template<bool weak, class T1 = smart_ptr<MetaObject>, class T2 = T1>
struct hash_comparator : public std::binary_function<T1, T2, bool>
{
  bool operator()(const first_argument_type &t1, const second_argument_type& t2) const
  { return t1->hash(weak) == t2->hash(weak); }
};

template<class T1, class T2 = T1>
struct AccessSorter : public std::binary_function<smart_ptr<T1>,smart_ptr<T2>,bool>
{
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getAccessQualifier() < rhs->getAccessQualifier(); }
};

struct AccessQualifierIs : public std::binary_function<smart_ptr<MetaObject>, size_t, bool>
{
  result_type operator()(const first_argument_type &tag, const second_argument_type &x) const
  { return (tag->getAccessQualifier() & x) != 0; }
};

template<class T1, class T2 = T1>
struct NameSorter : public std::binary_function<smart_ptr<T1>,smart_ptr<T2>,bool>
{
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getFQN().name() < rhs->getFQN().name(); }
};

template<class T1, class T2 = T1>
struct NameComparator : public std::binary_function<smart_ptr<T1>,smart_ptr<T2>,bool>
{
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getFQN().name() == rhs->getFQN().name(); }
};

template<class T1, class T2 = T1>
struct ScopeSorter : std::binary_function<smart_ptr<T1>, smart_ptr<T2>, bool> {
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getFQN().scope() < rhs->getFQN().scope(); }
};

template<class T1, class T2 = T1>
struct ScopeComparator : std::binary_function<smart_ptr<T1>, smart_ptr<T2>, bool> {
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getScopeName() < rhs->getScopeName(); }
};

template<class T1, class T2 = T1>
struct FQNSorter : public std::binary_function<smart_ptr<T1>,smart_ptr<T2>,bool>
{
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getFQN().toString() < rhs->getFQN().toString(); }
};

template<class T1, class T2 = T1>
struct FQNComparator : public std::binary_function<smart_ptr<T1>,smart_ptr<T2>,bool>
{
  bool operator()(const first_argument_type &lhs, const second_argument_type &rhs) const
  { return lhs->getFQN().toString() == rhs->getFQN().toString(); }
};

#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