EncoderArguments.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. */
  50. std::string getOutputPath() const;
  51. const std::vector<std::string>& getGroupAnimationNodeId() const;
  52. const std::vector<std::string>& getGroupAnimationAnimationId() const;
  53. bool containsGroupNodeId(const std::string& nodeId) const;
  54. const std::string getAnimationId(const std::string& nodeId) const;
  55. const std::vector<std::string>& getHeightmapNodeIds() const;
  56. /**
  57. * Returns true if an error occured while parsing the command line arguments.
  58. */
  59. bool parseErrorOccured() const;
  60. /**
  61. * Tests if a file exists on the file system.
  62. *
  63. * @return True if the file exists; false otherwise.
  64. */
  65. bool fileExists() const;
  66. /**
  67. * Prints the usage information.
  68. */
  69. void printUsage() const;
  70. bool fontPreviewEnabled() const;
  71. bool textOutputEnabled() const;
  72. bool DAEOutputEnabled() const;
  73. const char* getNodeId() const;
  74. unsigned int getFontSize() const;
  75. private:
  76. /**
  77. * Reads the command line option from the list of options starting at the given index.
  78. *
  79. * @param options The list of command line options.
  80. * @param index Pointer to the index within the options list. The index will be changed
  81. * if an option takes multiple arguments.
  82. */
  83. void readOption(const std::vector<std::string>& options, size_t *index);
  84. static std::string getRealPath(const std::string& filepath);
  85. /**
  86. * Replaces all instance of oldChar with newChar in str.
  87. */
  88. static void replace_char(char* str, char oldChar, char newChar);
  89. private:
  90. std::string _filePath;
  91. std::string _nodeId;
  92. std::string _daeOutputPath;
  93. unsigned int _fontSize;
  94. bool _parseError;
  95. bool _fontPreview;
  96. bool _textOutput;
  97. bool _daeOutput;
  98. std::vector<std::string> _groupAnimationNodeId;
  99. std::vector<std::string> _groupAnimationAnimationId;
  100. std::vector<std::string> _heightmapNodeIds;
  101. };
  102. }
  103. #endif