EncoderArguments.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef ENCODERARGUMENTS_H_
  2. #define ENCODERARGUMENTS_H_
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <iostream>
  6. #include <string>
  7. #include <sys/stat.h>
  8. #include <vector>
  9. #include "Base.h"
  10. /**
  11. * EncoderArguments handles parsing the command line arguments for the GamePlay Encoder.
  12. */
  13. class EncoderArguments
  14. {
  15. public:
  16. enum FileFormat
  17. {
  18. FILEFORMAT_UNKNOWN,
  19. FILEFORMAT_DAE,
  20. FILEFORMAT_TTF,
  21. FILEFORMAT_GPB
  22. };
  23. /**
  24. * Constructor.
  25. */
  26. EncoderArguments(size_t argc, const char** argv);
  27. /**
  28. * Destructor.
  29. */
  30. ~EncoderArguments(void);
  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* EncoderArguments::getFilePathPointer() const;
  43. /**
  44. * Returns the path to where the DAE output should be written to.
  45. */
  46. const std::string& EncoderArguments::getDAEOutputPath() const;
  47. const std::vector<std::string>& getGroupAnimationNodeId() const;
  48. const std::vector<std::string>& getGroupAnimationAnimationId() const;
  49. /**
  50. * Returns true if an error occured while parsing the command line arguments.
  51. */
  52. bool parseErrorOccured() const;
  53. /**
  54. * Tests if a file exists on the file system.
  55. *
  56. * @return True if the file exists; false otherwise.
  57. */
  58. bool fileExists() const;
  59. /**
  60. * Prints the usage information.
  61. */
  62. void printUsage() const;
  63. bool fontPreviewEnabled() const;
  64. bool textOutputEnabled() const;
  65. bool DAEOutputEnabled() const;
  66. const char* getNodeId() const;
  67. unsigned int getFontSize() const;
  68. private:
  69. /**
  70. * Reads the command line option from the list of options starting at the given index.
  71. *
  72. * @param options The list of command line options.
  73. * @param index Pointer to the index within the options list. The index will be changed
  74. * if an option takes multiple arguments.
  75. */
  76. void readOption(const std::vector<std::string>& options, size_t *index);
  77. static std::string getRealPath(const std::string& filepath);
  78. /**
  79. * Replaces all instance of oldChar with newChar in str.
  80. */
  81. static void replace_char(char* str, char oldChar, char newChar);
  82. private:
  83. std::string _filePath;
  84. std::string _nodeId;
  85. std::string _daeOutputPath;
  86. unsigned int _fontSize;
  87. bool _parseError;
  88. bool _fontPreview;
  89. bool _textOutput;
  90. bool _daeOutput;
  91. std::vector<std::string> _groupAnimationNodeId;
  92. std::vector<std::string> _groupAnimationAnimationId;
  93. };
  94. #endif