TsukiNi22/ai-utils / skills/cpp/cpp-class
cpp-class
VerifiedGenerate C++ (C++20) .hpp/.cpp files and class architectures in Tsukini's style (Xartania header, indented include guards, INCLUDE/CLASS sections, Pre-Function/Function/Operator/Constructor/Destructor blocks, libutils attributes or standard [[...]]), with empty bodies only (never the logic), then register the .cpp in the CMakeLists.txt. Also creates the main.cpp entry point in the same style. Use whenever the user asks to create, scaffold or add a C++ class, a main / entry point, interface (I*), abstract class (A*), template, struct/Type or Define header, module or set of .hpp/.cpp files.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.5 KB |
| examples/ASocket.cpp | other | 11.7 KB |
| examples/ASocket.hpp | other | 7.5 KB |
| examples/ArgParserType.hpp | other | 3.6 KB |
| examples/ISocket.hpp | other | 5.4 KB |
| examples/IdHandler.hpp | other | 8.3 KB |
| examples/NetworkDefine.hpp | other | 1.1 KB |
| examples/Scheduler.cpp | other | 2.5 KB |
| examples/Scheduler.hpp | other | 4.7 KB |
| reference/layout.md | markdown | 17.5 KB |
| requires.txt | markdown | 32 B |
| scripts/cmake_add.pyexecutable | script | 4.7 KB |
| scripts/detect_libutils.shexecutable | script | 1.5 KB |
| scripts/fonts/ansi_shadow.flf | other | 11.9 KB |
| scripts/header.pyexecutable | script | 4.2 KB |
| scripts/list_attributes.shexecutable | script | 1.6 KB |
| templates/abstract.hpp | other | 1.5 KB |
| templates/class.cpp | other | 262 B |
| templates/class.hpp | other | 1.5 KB |
| templates/define.hpp | other | 463 B |
| templates/family.hpp | other | 417 B |
| templates/interface.hpp | other | 1.2 KB |
| templates/main-std.cpp | other | 474 B |
| templates/main.cpp | other | 753 B |
| templates/template.hpp | other | 1.6 KB |
| templates/type.hpp | other | 823 B |
examples/ISocket.hpp
View on GitHub/**************************************************************\
██╗ ██╗ █████╗ ██████╗ ████████╗ █████╗ ███╗ ██╗██╗ █████╗
╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗████╗ ██║██║██╔══██╗
╚███╔╝ ███████║██████╔╝ ██║ ███████║██╔██╗ ██║██║███████║
██╔██╗ ██╔══██║██╔══██╗ ██║ ██╔══██║██║╚██╗██║██║██╔══██║
██╔╝ ██╗██║ ██║██║ ██║ ██║ ██║ ██║██║ ╚████║██║██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
Edition:
## @date 29/08/2026 by @author Tsukini
File Name:
## @file ISocket.hpp
File Description:
## Interface for socket handling
\**************************************************************/
#ifndef ISOCKET_H
#define ISOCKET_H
//----------------------------------------------------------------//
/* INCLUDE */
/* type */
#include "../../security/observer/Observer.hpp" // utils::security::observer::Observer
#include "../../attribute/Attribute.hpp" // _migration
#include "../NetworkType.hpp" // utils::network::Address
#include <sys/socket.h> // socklen_t
#include <sys/types.h> // ssize_t
#include <cstddef> // std::size_t
#include <vector> // std::vector
#include <string> // std::string
namespace utils::network { // namespace start
//----------------------------------------------------------------//
/* CLASS */
// Any fd that equal to -1 is an undefined fd
class ISocket: private utils::security::observer::Observer<"ISocket"> {
protected:
// ---------- Pre-Function -------- //
virtual void buffered(const std::string& s, int fd) = 0; // store the given string into the internal buffer
public:
// ---------- Pre-Function -------- //
/* setter */
virtual void setPayloadSeparator(char c) = 0; // default: '\n'
virtual void setPayloadSeparator(std::string s) = 0;
virtual void setChunckSize(std::size_t size) = 0; // default: 4096
virtual void setOverflow(std::size_t overflow) = 0; // size without a valid payload before throw, default: 4096 (0 = unlimited)
/* getter */
virtual int getFd(void) const = 0; // fd of the socket (-1 == closed)
virtual bool hasAcceptOverload(void) const = 0;
virtual bool hasRecvOverload(void) const = 0;
virtual bool hasSendOverload(void) const = 0;
// Can only be call one time, otherwise throw
virtual void connect(const utils::network::Address& address) = 0; // build a connection as a client
virtual void listen(const utils::network::Address& address) = 0; // build a connection as a server
virtual void reset(void) = 0; // reset fd (DOES NOT CLOSE!!!)
virtual void close(void) noexcept = 0; // reallow the use of connect/listen
// Only in server mode, otherwise throw
virtual int accept(void) = 0; // accept a new connection (only server mode), fd is used as an id in server
/* raw */
virtual int accept(int fd, sockaddr* addr, socklen_t* len) const = 0;
virtual ssize_t recv(int fd, char* buf, std::size_t len) const = 0;
virtual ssize_t send(int fd, const char* buf, std::size_t len) const = 0;
// fd = -1 -> redirect on self (default value)
virtual bool empty(int fd = -1) const = 0; // is there no valid payload in the stored buffer ?
virtual std::string recv(int fd = -1) = 0; // (default) read by chunck of 4096, store the payload overflow into a buffer
virtual std::vector<std::string> recvAll(int fd = -1) = 0; // read by chunck of 4096, return all valid payloads from the buffer, store the overflow into a buffer
virtual void flush(int fd = -1) = 0; // send the internal buffer
virtual std::size_t receive(int fd = -1) = 0; // read once (after a poll event) into the internal buffer, never wait for a full payload
virtual void discard(int fd = -1) = 0; // forget the internal buffers of a fd (closed connection), -1 = every fd
virtual void send(const std::string& s, int fd = -1) = 0; // (default) send it now
virtual void sendBuffered(const std::string& s, int fd = -1) = 0; // store in a buffer
// ------------ Operator ---------- //
ISocket& operator=(const ISocket& other) = delete;
ISocket& operator=(ISocket&& other) = delete;
// ---------- Constructor --------- //
ISocket() = default;
ISocket(const ISocket& other) = delete;
ISocket(ISocket&& other) = delete;
// ----------- Destructor --------- //
virtual ~ISocket() = default;
};
} // namespace end
//----------------------------------------------------------------//
/* MIGRATION */
namespace utils::network {
using ISocket _migration(4, 0, 0) = utils::network::ISocket;
}
#endif /* ISOCKET_H */
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |