home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / audio_sdk / src / AudioScript / Script.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-28  |  1.9 KB  |  116 lines

  1. /***********************************************************\
  2. Copyright (C) James Boer, 2002. 
  3. All rights reserved worldwide.
  4.  
  5. This software is provided "as is" without express or implied
  6. warranties. You may freely copy and compile this source into
  7. applications you distribute provided that the copyright text
  8. below is included in the resulting source code, for example:
  9. "Portions Copyright (C) James Boer, 2002"
  10. \***********************************************************/
  11. #ifndef SCRIPT_H__
  12. #define SCRIPT_H__
  13.  
  14. #include "Audio.h"
  15. #include "Lexer.h"
  16.  
  17. namespace Audio
  18. {
  19.  
  20. class ScriptNode;
  21.  
  22. typedef std::vector<Token*> DataChunk;
  23.  
  24. class Script
  25. {
  26. public:
  27.  
  28.     enum SCRIPT_TYPE
  29.     {
  30.         NO_NODE_DATA = 0,
  31.         VARIABLE,
  32.         STRING,
  33.         INTEGER,
  34.         REAL,
  35.         BOOLEAN,
  36.         VECTOR,
  37.         SCRIPT_GUID
  38.     };
  39.  
  40.     Script();
  41.     ~Script();
  42.  
  43.     ScriptNode* GetRoot();
  44.  
  45. private:
  46.     friend class ScriptLoader;
  47.     void Clear();
  48.  
  49.     TokenList    m_TokenList;
  50.     ScriptNode*    m_pRoot;
  51. };
  52.  
  53.  
  54. class ScriptNode
  55. {
  56. public:
  57.     ScriptNode();
  58.     ~ScriptNode();
  59.  
  60.     // Name
  61.     const char* GetName();
  62.  
  63.     // Data
  64.     Script::SCRIPT_TYPE GetDataType();
  65.     const char* GetString();
  66.     const char* GetVariable();
  67.     int GetInteger();
  68.     bool GetBool();
  69.     double GetReal();
  70.     AUDIOVECTOR GetVector();
  71.     GUID GetGuid();
  72.  
  73.     // Navigation
  74.     bool HasData();
  75.     ScriptNode* GetSibling();
  76.     ScriptNode* GetChild();
  77.     ScriptNode* GetParent();
  78.  
  79.     
  80.  
  81. private:
  82.     friend ScriptLoader;
  83.     friend Script;
  84.     void Clear();
  85.  
  86.     Token*            m_pName;
  87.     Token*            m_pData;
  88.     ScriptNode*        m_pParent;
  89.     ScriptNode*        m_pSibling;
  90.     ScriptNode*        m_pChild;
  91. };
  92.  
  93. class ScriptLoader
  94. {
  95. public:
  96.     ScriptLoader();
  97.     ~ScriptLoader();
  98.  
  99.     void Clear();
  100.  
  101.     bool Init();
  102.     void Term();
  103.  
  104.     bool Load(std::string sFileName, Script& script);
  105.     bool Load(uint8* pData, uint32 nDataLength, Script& script);
  106.  
  107. private:
  108.     bool BuildNodeTree(Script& script);
  109.  
  110.     Lexer    m_Lexer;
  111.  
  112. };
  113.  
  114. }; // namespace Audio
  115.  
  116. #endif // SCRIPT_H__