⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fooobject.h

📁 用于词法分析的词法分析器
💻 H
字号:
/*  $Id: FooObject.h,v 1.7 1997/02/02 01:31:01 matt Exp $  FooObject class.    (c) July 96 Matt Phillips*/#ifndef _FOO_OBJECT_H#define _FOO_OBJECT_H#include <std/string.h>#include <util/strhash.h>#include <contain/LinkedListWithTail.h>#include <contain/OpenHash.h>class FooObject{public:  class Hash  {  public:    static int hash (const string &str) {return ::hash (str);}  };  typedef TypeIOLinkedListWithTail(FooObject) Objects;  typedef TypeIOOpenHash(string, Objects, Hash) Attrs;  typedef Attrs::Iterator Iterator;  FooObject ();  FooObject (const string &value);  ~FooObject ();  // 				 add  //----------------------------------------------------------------------  // add value to list for attr.  void addAttr (const string &attr, FooObject &value);  // add values to list for attr.  void addAttr (const string &attr, const Objects &values);  // add (or replace) string value attribute.  void addAttr (const string &value);  // 				remove  //----------------------------------------------------------------------  // returns true if attr was sucessfully deleted.  int removeAttr (const string &attr);  // returns true if string value attribute was sucessfully deleted.  int removeAttr ();  // 				 get  //----------------------------------------------------------------------  // return values for attr, an empty list is returned if attr does  // not exist.  const Objects &getAttrs (const string &attr) const;  // return values for attr. attr is created if it does not exist.  Objects &getOrCreateAttrs (const string &attr);  // returns last value of attr or null if attribute does not exist.  FooObject *getAttr (const string &attr) const;  // returns string value attribute or empty string if attr does not  // exist.  const string &getAttr () const;  int getAttrInt () const;  // returns string value attribute or creates it if attr does not  // exist.  string &getOrCreateAttr ();  // return string value attribute of object referenced by attr or ''  // if attr does not exist.  const string &getAttrString (const string &attr) const;  // return int conversion of string value attribute of object  // referenced by attr or 0 if attr does not exist or is not a  // number.  int getAttrInt (const string &attr) const;  // return an iterator for all attributes in object except string  // value attribute.  Iterator getIter () const;  // 			get via attribute path  //----------------------------------------------------------------------  // returns last value of values pointed to by attribute path.  FooObject *getAttrPath (const string &path) const;  // returns values for attribute path of form 'attr1/attr2/...' or  // null if any element of path does not exist.  Objects *getAttrsPathPtr (const string &attr) const;  // returns values for attribute path or empty list if any element of  // path does not exist.  const Objects &getAttrsPath (const string &attr) const;  // returns string attribute of object at end of path or null if any  // element of path does not exist.  string *getAttrStringPathPtr (const string &path) const;  // returns string attribute of object at end of path or '' if any  // element of path does not exist.  const string &getAttrStringPath (const string &path) const;  // same as getAttrInt () but follows an attribute path.  returns 0  // if path does not exist or where getAttrInt () would return 0.  int getAttrIntPath (const string &path) const;  // 				 misc  //----------------------------------------------------------------------  // true if object has an attribute called attr.  int hasAttr (const string &attr) const {return attrs && attrs->get (attr);}  // true if object has a string value attribute.  int hasAttr () const {return stringValue != 0;}  // returns the number of attributes in this object except the string  // value.  int nAttrs () const;  // true if object has no attributes except the string value.  int isAtomic () const {return hasAttr () && nAttrs () == 0;}protected:  Objects *getAttrValues (const string &attr) const;  Attrs *attrs;  string *stringValue;  static const Objects emptyList;  static const Attrs emptyAttrs;  static const string emptyString;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -