logo

libbulletml

Library of Bullet Markup Language (forked from https://shinh.skr.jp/libbulletml/index_en.html )git clone https://hacktivis.me/git/libbulletml.git

bulletmltree.h (2224B)


  1. /// BulletMLツリー。
  2. /**
  3. * BulletML に特化していて非常にいんちきくさいのが特徴。
  4. */
  5. #ifndef BULLETMLTREE_H_
  6. #define BULLETMLTREE_H_
  7. #include <string>
  8. #include <algorithm>
  9. #include <memory>
  10. #include <vector>
  11. #include "tree.h"
  12. #include "formula.h"
  13. #include "bulletmlcommon.h"
  14. class BulletMLNode : public TreeNode<BulletMLNode> {
  15. public:
  16. typedef Formula<double> Number;
  17. typedef enum { none, aim, absolute, relative, sequence, typeSize } Type;
  18. typedef enum { bullet, action, fire, changeDirection, changeSpeed, accel,
  19. wait, repeat, bulletRef, actionRef, fireRef, vanish,
  20. horizontal, vertical, term, times, direction, speed, param,
  21. bulletml, nameSize } Name;
  22. private:
  23. static Type string2type(const std::string& str);
  24. static Name string2name(const std::string& str);
  25. static std::string name2string[nameSize];
  26. public:
  27. typedef TreeNode<BulletMLNode>::Children Children;
  28. typedef TreeNode<BulletMLNode>::ChildIterator ChildIterator;
  29. public:
  30. DECLSPEC explicit BulletMLNode(const std::string& name);
  31. DECLSPEC virtual ~BulletMLNode();
  32. DECLSPEC Name getName() const { return name_; }
  33. DECLSPEC void setValue(const std::string& val);
  34. DECLSPEC double getValue() const { return val_->value(); }
  35. DECLSPEC void setType(const std::string& type) { type_ = string2type(type); }
  36. DECLSPEC Type getType() const { return type_; }
  37. DECLSPEC void setRefID(int id) { refID_ = id; }
  38. DECLSPEC int getRefID() const { return refID_; }
  39. DECLSPEC BulletMLNode* getChild(Name name);
  40. /*
  41. template <class OutIte_>
  42. void getAllChildren(Name name, OutIte_ outIte);
  43. */
  44. DECLSPEC void getAllChildrenVec(Name name, std::vector<BulletMLNode*>& outvec);
  45. /// 子孫の中に指定した名前に一致するものがあるかどうか
  46. DECLSPEC bool findNode(Name name) const;
  47. DECLSPEC BulletMLNode* next();
  48. virtual void dump();
  49. protected:
  50. Name name_;
  51. Type type_;
  52. int refID_;
  53. std::auto_ptr<Number> val_;
  54. };
  55. /*
  56. template <class OutIte_>
  57. void BulletMLNode::getAllChildren(Name name, OutIte_ outIte) {
  58. ChildIterator ite;
  59. for (ite = childBegin(); ite != childEnd(); ite++) {
  60. if ((*ite)->getName() == name) *outIte = *ite;
  61. outIte++;
  62. }
  63. }
  64. */
  65. #endif // ! BULLETMLTREE_H_