ASResult.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <sstream>
  24. #include <string>
  25. #include <vector>
  26. using namespace std;
  27. namespace ASBindingGenerator
  28. {
  29. class ASGeneratedFile_Base
  30. {
  31. protected:
  32. // List of all required header files
  33. vector<string> headers_;
  34. // Discarded header files for statistic
  35. vector<string> ignoredHeaders_;
  36. // Result file path
  37. string outputFilePath_;
  38. void WriteHeaders(ofstream& stream);
  39. public:
  40. // Wrappers
  41. stringstream glue_;
  42. // Registration function body
  43. stringstream reg_;
  44. // Add header to list if not added yet
  45. void AddHeader(const string& headerFile);
  46. void AddIgnoredHeader(const string& headerFile);
  47. // Write result to file
  48. virtual void Save() {};
  49. };
  50. class ASGeneratedFile_WithRegistrationFunction : public ASGeneratedFile_Base
  51. {
  52. protected:
  53. // Registration function name
  54. string functionName_;
  55. public:
  56. ASGeneratedFile_WithRegistrationFunction(const string& outputFilePath, const string& functionName);
  57. };
  58. class ASGeneratedFile_Enums : public ASGeneratedFile_WithRegistrationFunction
  59. {
  60. public:
  61. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  62. void Save() override;
  63. };
  64. class ASGeneratedFile_Classes : public ASGeneratedFile_WithRegistrationFunction
  65. {
  66. public:
  67. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  68. void Save() override;
  69. };
  70. class ASGeneratedFile_Members_HighPriority : public ASGeneratedFile_WithRegistrationFunction
  71. {
  72. public:
  73. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  74. void Save() override;
  75. };
  76. class ASGeneratedFile_Members : public ASGeneratedFile_WithRegistrationFunction
  77. {
  78. public:
  79. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  80. void Save() override;
  81. };
  82. class ASGeneratedFile_GlobalVariables : public ASGeneratedFile_WithRegistrationFunction
  83. {
  84. public:
  85. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  86. void Save() override;
  87. };
  88. class ASGeneratedFile_GlobalFunctions : public ASGeneratedFile_WithRegistrationFunction
  89. {
  90. public:
  91. using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
  92. void Save() override;
  93. };
  94. class ASGeneratedFile_Templates : public ASGeneratedFile_Base
  95. {
  96. public:
  97. ASGeneratedFile_Templates(const string& outputFilePath);
  98. // Write result to file
  99. void Save() override;
  100. };
  101. }