Skip to content

Unsigned-Long/Code-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cpp Source Code Generator

Author : csl
E-Mail : 3079625093@qq.com

Override

This is a program for automatically generating cpp code. At present, it can automatically generate "struct" "enum" and "cpp project struct".

Struct Generator

Usage

mystructGenor StructName MemName1:MemType1 [MemName2:MemType2] ...

Example

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;
}

Enum Generator

Usage

myenumGenor EnumName Option1 [Option2] ...

Example

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;
};

CppProj Generator

Usage

mycppprojGenor projectName

Example

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

Other Examples

generator 'Car' struct

generator 'Color' enum

About

automatically generating cpp code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published