EncoderArguments.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef ENCODERARGUMENTS_H_
  2. #define ENCODERARGUMENTS_H_
  3. namespace gameplay
  4. {
  5. /**
  6. * EncoderArguments handles parsing the command line arguments for the GamePlay Encoder.
  7. */
  8. class EncoderArguments
  9. {
  10. public:
  11. enum FileFormat
  12. {
  13. FILEFORMAT_UNKNOWN,
  14. FILEFORMAT_DAE,
  15. FILEFORMAT_FBX,
  16. FILEFORMAT_TTF,
  17. FILEFORMAT_GPB
  18. };
  19. /**
  20. * Constructor.
  21. */
  22. EncoderArguments(size_t argc, const char** argv);
  23. /**
  24. * Destructor.
  25. */
  26. ~EncoderArguments(void);
  27. /**
  28. * Gets the EncoderArguments instance.
  29. */
  30. static EncoderArguments* getInstance();
  31. /**
  32. * Gets the file format from the file path based on the extension.
  33. */
  34. FileFormat getFileFormat() const;
  35. /**
  36. * Returns the file path.
  37. */
  38. const std::string& getFilePath() const;
  39. /**
  40. * Returns the char pointer to the file path string.
  41. */
  42. const char* getFilePathPointer() const;
  43. /**
  44. * Returns the path to where the DAE output should be written to.
  45. */
  46. const std::string& getDAEOutputPath() const;
  47. /**
  48. * Returns the output path/folder.
  49. * Example: "C:/dir"
  50. */
  51. std::string getOutputDirPath() const;
  52. /**
  53. * Returns the output file path.
  54. * Example: "C:/dir/scene.gpb"
  55. */
  56. std::string getOutputFilePath() const;
  57. const std::vector<std::string>& getGroupAnimationNodeId() const;
  58. const std::vector<std::string>& getGroupAnimationAnimationId() const;
  59. bool containsGroupNodeId(const std::string& nodeId) const;
  60. const std::string getAnimationId(const std::string& nodeId) const;
  61. const std::vector<std::string>& getHeightmapNodeIds() const;
  62. /**
  63. * Returns true if an error occurred while parsing the command line arguments.
  64. */
  65. bool parseErrorOccured() const;
  66. /**
  67. * Tests if a file exists on the file system.
  68. *
  69. * @return True if the file exists; false otherwise.
  70. */
  71. bool fileExists() const;
  72. /**
  73. * Prints the usage information.
  74. */
  75. void printUsage() const;
  76. bool fontPreviewEnabled() const;
  77. bool textOutputEnabled() const;
  78. bool DAEOutputEnabled() const;
  79. const char* getNodeId() const;
  80. unsigned int getFontSize() const;
  81. static std::string getRealPath(const std::string& filepath);
  82. private:
  83. /**
  84. * Reads the command line option from the list of options starting at the given index.
  85. *
  86. * @param options The list of command line options.
  87. * @param index Pointer to the index within the options list. The index will be changed
  88. * if an option takes multiple arguments.
  89. */
  90. void readOption(const std::vector<std::string>& options, size_t *index);
  91. void setInputfilePath(const std::string& inputPath);
  92. /**
  93. * Sets the output file path that the encoder will write to.
  94. */
  95. void setOutputfilePath(const std::string& outputPath);
  96. /**
  97. * Replaces all instance of oldChar with newChar in str.
  98. */
  99. static void replace_char(char* str, char oldChar, char newChar);
  100. private:
  101. std::string _filePath;
  102. std::string _fileOutputPath;
  103. std::string _nodeId;
  104. std::string _daeOutputPath;
  105. unsigned int _fontSize;
  106. bool _parseError;
  107. bool _fontPreview;
  108. bool _textOutput;
  109. bool _daeOutput;
  110. std::vector<std::string> _groupAnimationNodeId;
  111. std::vector<std::string> _groupAnimationAnimationId;
  112. std::vector<std::string> _heightmapNodeIds;
  113. };
  114. void unittestsEncoderArguments();
  115. }
  116. #endif