"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/include/Location.h" (5 Nov 2005, 4992 Bytes) of package /linux/misc/old/OpenSP-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Location.h" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1994 James Clark
    2 // See the file COPYING for copying permission.
    3 
    4 #ifndef Location_INCLUDED
    5 #define Location_INCLUDED 1
    6 #ifdef __GNUG__
    7 #pragma interface
    8 #endif
    9 
   10 #include "types.h"
   11 #include "Boolean.h"
   12 #include "Ptr.h"
   13 #include "Resource.h"
   14 #include "Boolean.h"
   15 #include "Vector.h"
   16 #include "Owner.h"
   17 #include "StringC.h"
   18 #include "rtti.h"
   19 
   20 #ifdef SP_NAMESPACE
   21 namespace SP_NAMESPACE {
   22 #endif
   23 
   24 class ExternalInfo;
   25 class EntityOrigin;
   26 class InputSourceOrigin;
   27 class Entity;
   28 class EntityDecl;
   29 class Location;
   30 class Markup;
   31 class Text;
   32 class NamedCharRef;
   33 
   34 class SP_API Origin : public Resource {
   35 public:
   36   virtual ~Origin();
   37   virtual const EntityOrigin *asEntityOrigin() const;
   38   virtual const InputSourceOrigin *asInputSourceOrigin() const;
   39   virtual const Location &parent() const = 0;
   40   virtual Index refLength() const;
   41   virtual Boolean origChars(const Char *&) const;
   42   virtual Boolean inBracketedTextOpenDelim() const;
   43   virtual Boolean inBracketedTextCloseDelim() const;
   44   virtual Boolean isNumericCharRef(const Markup *&markup) const;
   45   virtual Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const;
   46   virtual const EntityDecl *entityDecl() const;
   47   virtual Boolean defLocation(Offset off, const Origin *&, Index &) const;
   48   virtual const Markup *markup() const;
   49   virtual const Entity *entity() const;
   50   virtual const ExternalInfo *externalInfo() const;
   51   virtual Offset startOffset(Index ind) const;
   52   const StringC *entityName() const;
   53 };
   54 
   55 class SP_API ProxyOrigin : public Origin {
   56 public:
   57   ProxyOrigin(const Origin *origin);
   58   const EntityOrigin *asEntityOrigin() const;
   59   const InputSourceOrigin *asInputSourceOrigin() const;
   60   const Location &parent() const;
   61   Index refLength() const;
   62   Boolean origChars(const Char *&) const;
   63   Boolean inBracketedTextOpenDelim() const;
   64   Boolean inBracketedTextCloseDelim() const;
   65   Boolean isNumericCharRef(const Markup *&markup) const;
   66   Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const;
   67   const EntityDecl *entityDecl() const;
   68   Boolean defLocation(Offset off, const Origin *&, Index &) const;
   69   const Markup *markup() const;
   70   const Entity *entity() const;
   71   const ExternalInfo *externalInfo() const;
   72   Offset startOffset(Index ind) const;
   73 private:
   74   const Origin *origin_;
   75 };
   76 
   77 class SP_API Location {
   78 public:
   79   Location();
   80   Location(const Location&);
   81   Location(Origin *, Index);
   82   Location(ConstPtr<Origin>, Index);
   83   void operator+=(Index i) { index_ += i; }
   84   void operator-=(Index i) { index_ -= i; }
   85   Index index() const { return index_; }
   86   const ConstPtr<Origin> &origin() const { return origin_; }
   87   void clear() { origin_.clear(); }
   88   void swap(Location &to) {
   89     origin_.swap(to.origin_);
   90     Index tem = to.index_;
   91     to.index_ = index_;
   92     index_ = tem;
   93   }
   94 private:
   95   ConstPtr<Origin> origin_;
   96   Index index_;
   97 };
   98 
   99 class SP_API ExternalInfo {
  100   RTTI_CLASS
  101 public:
  102   virtual ~ExternalInfo();
  103 };
  104 
  105 class SP_API NamedCharRef {
  106 public:
  107   enum RefEndType {
  108     endOmitted,
  109     endRE,
  110     endRefc
  111     };
  112   NamedCharRef();
  113   NamedCharRef(Index, RefEndType, const StringC &);
  114   Index refStartIndex() const;
  115   RefEndType refEndType() const;
  116   const StringC &origName() const;
  117   void set(Index, RefEndType, const Char *, size_t);
  118 private:
  119   Index refStartIndex_;
  120   RefEndType refEndType_;
  121   StringC origName_;
  122 };
  123 
  124 struct SP_API InputSourceOriginNamedCharRef {
  125   Index replacementIndex;
  126   size_t origNameOffset;
  127   Index refStartIndex;
  128   NamedCharRef::RefEndType refEndType;
  129 };
  130 
  131 class SP_API InputSourceOrigin : public Origin {
  132 public:
  133   virtual ~InputSourceOrigin() = 0;
  134   virtual void noteCharRef(Index replacementIndex, const NamedCharRef &) = 0;
  135   virtual void setExternalInfo(ExternalInfo *) = 0;
  136   virtual InputSourceOrigin *copy() const = 0;
  137   static InputSourceOrigin *make();
  138   static InputSourceOrigin *make(const Location &refLocation);
  139 };
  140 
  141 // a delimiter specified in bracketed text
  142 
  143 class SP_API BracketOrigin : public Origin {
  144 public:
  145   enum Position { open, close };
  146   BracketOrigin(const Location &, Position);
  147   const Location &parent() const;
  148   Boolean inBracketedTextOpenDelim() const;
  149   Boolean inBracketedTextCloseDelim() const;
  150 private:
  151   Position pos_;
  152   Location loc_;
  153 };
  154 
  155 class SP_API ReplacementOrigin : public Origin {
  156 public:
  157   ReplacementOrigin(const Location &, Char origChar);
  158   const Location &parent() const;
  159   Boolean origChars(const Char *&) const;
  160 private:
  161   Location loc_;
  162   Char origChar_;
  163 };
  164 
  165 class SP_API MultiReplacementOrigin : public Origin {
  166 public:
  167   MultiReplacementOrigin(const Location &, StringC &origChars);
  168   const Location &parent() const;
  169   Boolean origChars(const Char *&) const;
  170 private:
  171   Location loc_;
  172   StringC origChars_;
  173 };
  174 
  175 inline
  176 Index NamedCharRef::refStartIndex() const
  177 {
  178   return refStartIndex_;
  179 }
  180 
  181 inline
  182 NamedCharRef::RefEndType NamedCharRef::refEndType() const
  183 {
  184   return refEndType_;
  185 }
  186 
  187 inline
  188 const StringC &NamedCharRef::origName() const
  189 {
  190   return origName_;
  191 }
  192 
  193 #ifdef SP_NAMESPACE
  194 }
  195 #endif
  196 
  197 #endif /* not Location_INCLUDED */