Author : csl
E-Mail : 3079625093@qq.com
This is a program for automatically generating cpp code. At present, it can automatically generate "struct" "enum" and "cpp project struct".
mystructGenor StructName MemName1:MemType1 [MemName2:MemType2] ...
mystructGenor Info id:uint
struct Info
{
private:
/**
* @brief the members
*/
uint _id;
public:
/**
* @brief construct a new Info object
*/
Info(const uint &id)
: _id(id) {}
inline uint &id() { return this->_id; }
inline const uint &id() const { return this->_id; }
};
/**
* @brief override operator '<<' for type 'Info'
*/
std::ostream &operator<<(std::ostream &os, const Info &obj)
{
os << '{';
os << " 'id' : " << obj.id();
os << '}';
return os;
}
myenumGenor EnumName Option1 [Option2] ...
myenumGenor Color red green blue
enum class Color
{
/**
* @brief options
*/
RED,
GREEN,
BLUE
};
/**
* @brief override operator '<<' for type 'Color'
*/
std::ostream &operator<<(std::ostream &os, const Color &obj)
{
switch (obj)
{
case Color::RED:
os << " RED ";
break;
case Color::GREEN:
os << " GREEN ";
break;
case Color::BLUE:
os << " BLUE ";
break;
}
return os;
};
mycppprojGenor projectName
mystructGenor test
test/
├── bash
│ ├── cmake.sh
│ └── makerun.sh
├── bin
├── build
├── CMakeLists.txt
├── include
│ └── test.h
├── main.cpp
├── readme.md
└── src
└── test.cpp
└── thirdparty
├── include
└── lib
5 directories, 7 files