File tree Expand file tree Collapse file tree 3 files changed +54
-5
lines changed
Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -364,4 +364,32 @@ namespace bin2cpp
364364 return output;
365365 }
366366
367+ CodeGenerationEnum parseCode (const std::string& value)
368+ {
369+ std::string value_upper = ra::strings::Uppercase (value);
370+ if ( value_upper == " C" )
371+ return CodeGenerationEnum::CODE_GENERATION_C;
372+ if ( value_upper == " CPP" || value_upper == " C++" )
373+ return CodeGenerationEnum::CODE_GENERATION_CPP;
374+ return CodeGenerationEnum::CODE_GENERATION_UNKNOW;
375+ }
376+
377+ const std::string& getDefaultCodeSourceFileExtension (CodeGenerationEnum code)
378+ {
379+ static const std::string EMPTY = " " ;
380+ static const std::string CPP = " cpp" ;
381+ static const std::string C = " c" ;
382+ switch ( code )
383+ {
384+ case CODE_GENERATION_UNKNOW:
385+ return EMPTY;
386+ case CODE_GENERATION_CPP:
387+ return CPP;
388+ case CODE_GENERATION_C:
389+ return C;
390+ default :
391+ return EMPTY;
392+ };
393+ }
394+
367395}; // bin2cpp
Original file line number Diff line number Diff line change 3232#include < vector>
3333
3434#include " types.h"
35+ #include " enums.h"
3536
3637namespace bin2cpp
3738{
@@ -142,6 +143,20 @@ namespace bin2cpp
142143 // /<return>Returns the combined string.<return>
143144 std::string strJoin (const std::vector<std::string>& values, char separator);
144145
146+ // /<summary>
147+ // /Parse a CodeGenerationEnum from a string.
148+ // /</summary>
149+ // /<param name="value">The string value representing of the code language.</param>
150+ // /<return>Returns a valid CodeGenerationEnum value. Returns CODE_GENERATION_UNKNOW on parsing error.<return>
151+ CodeGenerationEnum parseCode (const std::string& value);
152+
153+ // /<summary>
154+ // /Get the default source file extension for the given CodeGenerationEnum.
155+ // /</summary>
156+ // /<param name="code">The code generation language.</param>
157+ // /<return>Returns a valid file extension valu that matches the given code. Returns an empty string otherwise.<return>
158+ const std::string & getDefaultCodeSourceFileExtension (CodeGenerationEnum code);
159+
145160}; // bin2cpp
146161
147162#endif // BIN2CPP_COMMON_H
Original file line number Diff line number Diff line change 2424
2525#ifndef ENUMS_H
2626#define ENUMS_H
27-
28- #include < string>
29- #include " Context.h"
3027
3128namespace bin2cpp
3229{
3330
3431 // /<summary>
35- // /Defines the different type of cpp encoding.
36- // /See setCppEncoder() and getCppEncoder() functions.
32+ // /Defines the different types of cpp encoding.
3733 // /</summary>
3834 enum CppEncoderEnum
3935 {
4036 CPP_ENCODER_OCT,
4137 CPP_ENCODER_HEX,
4238 };
39+
40+ // /<summary>
41+ // /Defines the different types of programming language code output.
42+ // /</summary>
43+ enum CodeGenerationEnum
44+ {
45+ CODE_GENERATION_UNKNOW,
46+ CODE_GENERATION_CPP,
47+ CODE_GENERATION_C,
48+ };
4349
4450}; // bin2cpp
4551
You can’t perform that action at this time.
0 commit comments