mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
添加文本转换器代码
This commit is contained in:
16
others/C++/text converter/include/About.hpp
Normal file
16
others/C++/text converter/include/About.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef ABOUT_HPP
|
||||
#define ABOUT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class About {
|
||||
public:
|
||||
static std::string getName() { return "文本转换器"; }
|
||||
static std::string getVersion() { return "1.0.0"; }
|
||||
static std::string getAuthor() { return "zsyg"; }
|
||||
static std::string getDescription() {
|
||||
return "一个简单的文本转换工具,支持文本转换";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ABOUT_HPP
|
||||
13
others/C++/text converter/include/Ascii85Converter.hpp
Normal file
13
others/C++/text converter/include/Ascii85Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ASCII85CONVERTER_HPP
|
||||
#define ASCII85CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Ascii85Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Ascii85"; }
|
||||
};
|
||||
|
||||
#endif // ASCII85CONVERTER_HPP
|
||||
13
others/C++/text converter/include/Base32Converter.hpp
Normal file
13
others/C++/text converter/include/Base32Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef BASE32CONVERTER_HPP
|
||||
#define BASE32CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Base32Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Base32"; }
|
||||
};
|
||||
|
||||
#endif // BASE32CONVERTER_HPP
|
||||
13
others/C++/text converter/include/Base64Converter.hpp
Normal file
13
others/C++/text converter/include/Base64Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef BASE64CONVERTER_HPP
|
||||
#define BASE64CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Base64Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Base64"; }
|
||||
};
|
||||
|
||||
#endif // BASE64CONVERTER_HPP
|
||||
14
others/C++/text converter/include/BinaryConverter.hpp
Normal file
14
others/C++/text converter/include/BinaryConverter.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef BINARYCONVERTER_HPP
|
||||
#define BINARYCONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <bitset>
|
||||
|
||||
class BinaryConverter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "二进制"; }
|
||||
};
|
||||
|
||||
#endif // BINARYCONVERTER_HPP
|
||||
13
others/C++/text converter/include/CRC32Converter.hpp
Normal file
13
others/C++/text converter/include/CRC32Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef CRC32CONVERTER_HPP
|
||||
#define CRC32CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class CRC32Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "CRC32"; }
|
||||
};
|
||||
|
||||
#endif // CRC32CONVERTER_HPP
|
||||
30
others/C++/text converter/include/Config.hpp
Normal file
30
others/C++/text converter/include/Config.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef CONFIG_HPP
|
||||
#define CONFIG_HPP
|
||||
|
||||
namespace Config {
|
||||
constexpr int WINDOW_WIDTH = 450;
|
||||
constexpr int WINDOW_HEIGHT = 250;
|
||||
constexpr const char* WINDOW_TITLE = "文本转换器";
|
||||
|
||||
constexpr int INPUT_X = 70;
|
||||
constexpr int INPUT_Y = 40;
|
||||
constexpr int INPUT_WIDTH = 360;
|
||||
constexpr int INPUT_HEIGHT = 30;
|
||||
|
||||
constexpr int OUTPUT_X = 70;
|
||||
constexpr int OUTPUT_Y = 100;
|
||||
constexpr int OUTPUT_WIDTH = 360;
|
||||
constexpr int OUTPUT_HEIGHT = 30;
|
||||
|
||||
constexpr int CHOICE_X = 70;
|
||||
constexpr int CHOICE_Y = 160;
|
||||
constexpr int CHOICE_WIDTH = 120;
|
||||
constexpr int CHOICE_HEIGHT = 30;
|
||||
|
||||
constexpr int BUTTON_X = 210;
|
||||
constexpr int BUTTON_Y = 160;
|
||||
constexpr int BUTTON_WIDTH = 100;
|
||||
constexpr int BUTTON_HEIGHT = 30;
|
||||
};
|
||||
|
||||
#endif // CONFIG_HPP
|
||||
13
others/C++/text converter/include/Converter.hpp
Normal file
13
others/C++/text converter/include/Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef CONVERTER_HPP
|
||||
#define CONVERTER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class Converter {
|
||||
public:
|
||||
virtual ~Converter() = default;
|
||||
virtual std::string convert(const std::string& input) = 0;
|
||||
virtual std::string getName() const = 0;
|
||||
};
|
||||
|
||||
#endif // CONVERTER_HPP
|
||||
15
others/C++/text converter/include/HexConverter.hpp
Normal file
15
others/C++/text converter/include/HexConverter.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HEXCONVERTER_HPP
|
||||
#define HEXCONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
class HexConverter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "十六进制"; }
|
||||
};
|
||||
|
||||
#endif // HEXCONVERTER_HPP
|
||||
13
others/C++/text converter/include/MD5Converter.hpp
Normal file
13
others/C++/text converter/include/MD5Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef MD5CONVERTER_HPP
|
||||
#define MD5CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class MD5Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "MD5"; }
|
||||
};
|
||||
|
||||
#endif // MD5CONVERTER_HPP
|
||||
26
others/C++/text converter/include/MainWindow.hpp
Normal file
26
others/C++/text converter/include/MainWindow.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef MAINWINDOW_HPP
|
||||
#define MAINWINDOW_HPP
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
#include <FL/Fl_Output.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
|
||||
class MainWindow : public Fl_Window {
|
||||
public:
|
||||
MainWindow(int w, int h, const char* title);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Fl_Input* inputText;
|
||||
Fl_Output* outputText;
|
||||
Fl_Choice* conversionType;
|
||||
Fl_Button* convertButton;
|
||||
|
||||
static void ConvertCallback(Fl_Widget* widget, void* data);
|
||||
void ConvertText();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_HPP
|
||||
14
others/C++/text converter/include/ROT13Converter.hpp
Normal file
14
others/C++/text converter/include/ROT13Converter.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ROT13CONVERTER_HPP
|
||||
#define ROT13CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
|
||||
class ROT13Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "ROT13"; }
|
||||
};
|
||||
|
||||
#endif // ROT13CONVERTER_HPP
|
||||
13
others/C++/text converter/include/SHA1Converter.hpp
Normal file
13
others/C++/text converter/include/SHA1Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SHA1CONVERTER_HPP
|
||||
#define SHA1CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class SHA1Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "SHA1"; }
|
||||
};
|
||||
|
||||
#endif // SHA1CONVERTER_HPP
|
||||
13
others/C++/text converter/include/SHA256Converter.hpp
Normal file
13
others/C++/text converter/include/SHA256Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SHA256CONVERTER_HPP
|
||||
#define SHA256CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class SHA256Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "SHA256"; }
|
||||
};
|
||||
|
||||
#endif // SHA256CONVERTER_HPP
|
||||
14
others/C++/text converter/include/Utils.hpp
Normal file
14
others/C++/text converter/include/Utils.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
#include <memory>
|
||||
#include "Converter.hpp"
|
||||
#include "BinaryConverter.hpp"
|
||||
#include "HexConverter.hpp"
|
||||
|
||||
class Utils {
|
||||
public:
|
||||
static std::unique_ptr<Converter> createConverter(int type);
|
||||
};
|
||||
|
||||
#endif // UTILS_HPP
|
||||
Reference in New Issue
Block a user