Created
May 26, 2015 16:19
-
-
Save icedac/5df10fee6e399b720825 to your computer and use it in GitHub Desktop.
generated_code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generated by SQL COMPILER | |
// time : 2015-05-27 01:02:42.811 | |
// do not modify | |
// contact: icedac@gmail.com | |
#pragma once | |
#pragma warning(push) | |
#pragma warning(disable: 4100) // unreferenced formal parameter | |
namespace test_db { | |
using corn::FormatString; | |
inline const char* name_A() { return "test_db"; } | |
inline const wchar_t* name_W() { return L"test_db"; }; | |
inline const TCHAR* name() { return _T("test_db"); } | |
const int64_t version = 0x0000000000000009; // 9 | |
const int64_t minor_version = 0x01d097cd65f02070; // 130771297628070000 | |
/**************************************************************************** | |
* | |
* stored procedure: sp_version_check | |
*/ | |
struct sp_version_check | |
{ | |
static const char* name_A() { return "sp_version_check"; } | |
static const wchar_t* name_W() { return L"sp_version_check"; }; | |
static const TCHAR* name() { return _T("sp_version_check"); } | |
struct sp_t { | |
struct out_t { | |
std::int64_t version; // bigint | |
std::int64_t minor_version; // bigint | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_FROM_DB, version, "version") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_FROM_DB, minor_version, "minor_version") | |
END_OTLA_BINDING | |
} out; | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_SET_ARG, out.version, "version") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_SET_ARG, out.minor_version, "minor_version") | |
END_OTLA_BINDING | |
}; // struct sp { | |
// | |
oTLA::StoredProcedure<sp_t> sp; | |
oTLA::Search<sp_t::out_t> out; | |
template < typename UPDATER > | |
void open( UPDATER* u, const TCHAR* db_name = nullptr ) | |
{ | |
auto sp_name = FormatString(_T("%s.%s"), db_name ? db_name : test_db::name(), name() ).AsString(); | |
sp.Open(u, sp_name.c_str()); | |
out.Open(u,nullptr); | |
} | |
}; | |
template <typename E> | |
inline auto Enum_AsInt(E const value) | |
-> typename std::underlying_type<E>::type { | |
return static_cast<typename std::underlying_type<E>::type>(value); | |
} | |
enum class Error : std::int32_t { | |
SUCCESS = 0, | |
ERR_NOT_IMPLEMENTED = 1, | |
ERR_GENERAL = 2, | |
ERR_DB_SERVER = 4, | |
ERR_RESOURCE_NOT_FOUND = 300, | |
}; | |
// Error_AsStr | |
inline const char* Error_AsStrA(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return "SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return "ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return "ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return "ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return "ERR_RESOURCE_NOT_FOUND"; | |
} | |
return "Error::UNDEFINED"; | |
} | |
inline const wchar_t* Error_AsStrW(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return L"SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return L"ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return L"ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return L"ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return L"ERR_RESOURCE_NOT_FOUND"; | |
} | |
return L"Error::UNDEFINED"; | |
} | |
template < typename CharType > | |
inline const CharType* T_Error_AsStr(Error r); | |
template <> | |
inline const char* T_Error_AsStr(Error r) { return Error_AsStrA(r); } | |
template <> | |
inline const wchar_t* T_Error_AsStr(Error r) { return Error_AsStrW(r); } | |
inline const TCHAR* Error_AsStr(Error r) { return T_Error_AsStr<TCHAR>(r); } | |
// Error_AsDesc | |
inline const char* Error_AsDescA(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return "SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return "ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return "ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return "ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return "ERR_RESOURCE_NOT_FOUND"; | |
} | |
return "Error::UNDEFINED"; | |
} | |
inline const wchar_t* Error_AsDescW(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return L"SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return L"ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return L"ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return L"ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return L"ERR_RESOURCE_NOT_FOUND"; | |
} | |
return L"Error::UNDEFINED"; | |
} | |
template < typename CharType > | |
inline const CharType* T_Error_AsDesc(Error r); | |
template <> | |
inline const char* T_Error_AsDesc(Error r) { return Error_AsDescA(r); } | |
template <> | |
inline const wchar_t* T_Error_AsDesc(Error r) { return Error_AsDescW(r); } | |
inline const TCHAR* Error_AsDesc(Error r) { return T_Error_AsDesc<TCHAR>(r); } | |
/**************************************************************************** | |
* | |
* table: tbl_account | |
*/ | |
struct tbl_account | |
{ | |
static const char* name_A() { return "tbl_account"; } | |
static const wchar_t* name_W() { return L"tbl_account"; }; | |
static const TCHAR* name() { return _T("tbl_account"); }; | |
static std::basic_string<TCHAR> table_name( const TCHAR* db_name = nullptr ) | |
{ | |
return FormatString(_T("%s.%s"), db_name ? db_name : _T("test_db"), name()).AsString(); | |
} | |
struct table_t { | |
std::uint64_t acct_id; // bigint; 계정 Unique no | |
corn::TFixedStringA<50> acct_name; // varchar; | |
corn::TFixedStringA<50> nickname; // varchar; | |
oTLA::DB_Time_t creation_time; // timestamp; | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::FROM_DB, acct_id, "acct_id") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::FROM_DB, acct_name, "acct_name") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::FROM_DB, nickname, "nickname") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::FROM_DB, creation_time, "creation_time") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_id = (*this).acct_id; // std::uint64_t(bigint) | |
dst.acct_name = (*this).acct_name.c_str(); // corn::TFixedStringA<50>(varchar) | |
dst.nickname = (*this).nickname.c_str(); // corn::TFixedStringA<50>(varchar) | |
oTLA::time_db_to_timestamp(dst.creation_time, (*this).creation_time); // oTLA::DB_Time_t(timestamp) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_id = src.acct_id; // std::uint64_t(bigint) | |
(*this).acct_name = src.acct_name; // corn::TFixedStringA<50>(varchar) | |
(*this).nickname = src.nickname; // corn::TFixedStringA<50>(varchar) | |
oTLA::time_timestamp_to_db((*this).creation_time, src.creation_time); // oTLA::DB_Time_t(timestamp) | |
} | |
}; | |
// where clause classes | |
struct PK_by_acct_id { // PRIMARY_KEY | |
std::uint64_t acct_id; // bigint | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::UNIQUE_FIELD, acct_id, "acct_id") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_id = (*this).acct_id; // std::uint64_t(bigint) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_id = src.acct_id; // std::uint64_t(bigint) | |
} | |
}; | |
struct K_by_acct_name { // KEY | |
corn::TFixedStringA<50> acct_name; // varchar | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::UNIQUE_FIELD, acct_name, "acct_name") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_name = (*this).acct_name.c_str(); // corn::TFixedStringA<50>(varchar) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_name = src.acct_name; // corn::TFixedStringA<50>(varchar) | |
} | |
}; | |
struct PK_by_all { // PRIMARY_KEY_ALL | |
std::uint64_t acct_id; // bigint | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::TO_DB | oTLA::UNIQUE_FIELD, acct_id, "acct_id") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_id = (*this).acct_id; // std::uint64_t(bigint) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_id = src.acct_id; // std::uint64_t(bigint) | |
} | |
}; | |
template < typename DB > | |
static oTLA::Persist<table_t> persist(DB* db, const TCHAR* db_name = nullptr) | |
{ | |
oTLA::Persist<table_t> u(db, table_name(db_name).c_str() ); | |
return std::move(u); | |
} | |
template < typename DB, typename Where > | |
static oTLA::search_t<table_t, DB,Where> search(DB* db, const Where& where, const TCHAR* db_name = nullptr) | |
{ | |
oTLA::search_t<table_t, DB, Where> u(db, table_name(db_name).c_str(), where); | |
return std::move(u); | |
} | |
template < typename DB > | |
static oTLA::search_t<table_t, DB, oTLA::NullWhereClause> search(DB* db, const TCHAR* db_name = nullptr) | |
{ | |
oTLA::search_t<table_t, DB, oTLA::NullWhereClause> u(db, table_name(db_name).c_str(), oTLA::NullWhereClause()); | |
return std::move(u); | |
} | |
}; | |
/**************************************************************************** | |
* | |
* stored procedure: sp_get_account_by_name | |
*/ | |
struct sp_get_account_by_name | |
{ | |
static const char* name_A() { return "sp_get_account_by_name"; } | |
static const wchar_t* name_W() { return L"sp_get_account_by_name"; }; | |
static const TCHAR* name() { return _T("sp_get_account_by_name"); }; | |
static std::basic_string<TCHAR> sp_name( const TCHAR* db_name = nullptr ) | |
{ | |
return FormatString(_T("%s.%s"), db_name ? db_name : _T("test_db"), name()).AsString(); | |
} | |
struct sp_t { | |
struct { | |
corn::TFixedStringA<50> acct_name; // varchar | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_name = (*this).acct_name.c_str(); // corn::TFixedStringA<50>(varchar) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_name = src.acct_name; // corn::TFixedStringA<50>(varchar) | |
} | |
} in; | |
struct out_t { | |
std::uint32_t result; // int | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_FROM_DB, result, "result") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.result = (*this).result; // std::uint32_t(int) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).result = src.result; // std::uint32_t(int) | |
} | |
} out; | |
struct result_set_t { | |
std::uint64_t acct_id; // bigint | |
corn::TFixedStringA<50> acct_name; // varchar | |
corn::TFixedStringA<50> nickname; // varchar | |
oTLA::DB_Time_t creation_time; // timestamp | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_ARG, acct_id, "acct_id") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_ARG, acct_name, "acct_name") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_ARG, nickname, "nickname") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_ARG, creation_time, "creation_time") | |
END_OTLA_BINDING | |
template < typename T > | |
void copy_to(T& dst) const { | |
dst.acct_id = (*this).acct_id; // std::uint64_t(bigint) | |
dst.acct_name = (*this).acct_name.c_str(); // corn::TFixedStringA<50>(varchar) | |
dst.nickname = (*this).nickname.c_str(); // corn::TFixedStringA<50>(varchar) | |
oTLA::time_db_to_timestamp(dst.creation_time, (*this).creation_time); // oTLA::DB_Time_t(timestamp) | |
} | |
template < typename T > | |
void copy_from( const T& src) { | |
(*this).acct_id = src.acct_id; // std::uint64_t(bigint) | |
(*this).acct_name = src.acct_name; // corn::TFixedStringA<50>(varchar) | |
(*this).nickname = src.nickname; // corn::TFixedStringA<50>(varchar) | |
oTLA::time_timestamp_to_db((*this).creation_time, src.creation_time); // oTLA::DB_Time_t(timestamp) | |
} | |
}; | |
BEGIN_OTLA_BINDING | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_IN_ARG, in.acct_name, "acct_name") | |
OTLA_BIND_ATT_COLUMN_NAME(oTLA::SP_OUT_SET_ARG, out.result, "result") | |
END_OTLA_BINDING | |
}; // struct sp { | |
// | |
oTLA::StoredProcedure<sp_t> sp; | |
oTLA::Search<sp_t::out_t> out; | |
oTLA::Search<sp_t::result_set_t> result; | |
oTLA::Search<sp_t::result_set_t> result_end; | |
struct result_iterator { | |
oTLA::Search<sp_t::result_set_t>* s_; | |
result_iterator(oTLA::Search<sp_t::result_set_t>* s) : s_(s) {} | |
oTLA::Search<sp_t::result_set_t>::reference operator*() const { return *(*s_); } | |
oTLA::Search<sp_t::result_set_t>::pointer operator->() const { return (*s_).operator->(); } | |
bool operator!= (const result_iterator & rhs) const { return (*s_) != (*rhs.s_); } | |
result_iterator& operator++() { ++(*s_); return *this; } | |
}; | |
result_iterator begin() { | |
return result_iterator(&result); | |
} | |
result_iterator end() { | |
return result_iterator(&result_end); | |
} | |
int size() const { | |
return result.Get_Row_Processed_Count(); | |
} | |
template < typename UPDATER > | |
void open( UPDATER* u, const TCHAR* db_name = nullptr ) | |
{ | |
result.SetExternalResultStream(sp.Get_Result_Stream()); | |
sp.Open(u, sp_name(db_name).c_str(), result); | |
out.Open(u,nullptr); | |
} | |
sp_get_account_by_name() = delete; | |
template < typename T_acct_name > | |
explicit sp_get_account_by_name( const T_acct_name& acct_name ) { | |
sp->in.acct_name = acct_name; | |
} | |
}; | |
} // namespace | |
#pragma warning(pop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- generated by SQL COMPILER | |
-- time : 2015-05-27 01:02:42.815 | |
-- do not modify | |
-- contact: icedac@gmail.com | |
USE test_db; | |
SET FOREIGN_KEY_CHECKS=0; | |
-- version check sp | |
DROP PROCEDURE IF EXISTS `sp_version_check`; | |
DELIMITER // | |
CREATE PROCEDURE `sp_version_check`( OUT version BIGINT, OUT minor_version BIGINT ) | |
BEGIN | |
set version = 9; -- 0x0000000000000009 | |
set minor_version = 130771297628070000; -- 0x01d097cd65f02070 | |
END// | |
DELIMITER ; | |
-- **************************************************************************** | |
-- * | |
-- * table: tbl_account | |
-- */ | |
CREATE TABLE `tbl_account`( | |
`acct_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '계정 Unique no' | |
, `acct_name` varchar(50) NOT NULL | |
, KEY (`acct_name`) | |
, `nickname` varchar(50) NOT NULL | |
, `creation_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | |
, PRIMARY KEY (`acct_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
-- ---------------------------- | |
-- Records of tbl_account | |
-- ---------------------------- | |
INSERT INTO `tbl_account` VALUES ('100', 'icedac', '아이스닥', DEFAULT ); | |
-- **************************************************************************** | |
-- * | |
-- * stored procedure: sp_get_account_by_name | |
-- */ | |
DELIMITER // | |
CREATE PROCEDURE `sp_get_account_by_name`( | |
IN `acct_name` varchar(50) | |
, OUT `result` int UNSIGNED | |
) | |
BEGIN | |
select count(*) into result from tbl_account where tbl_account.acct_name = acct_name; | |
if ( result = 0 ) then | |
call sp_new_account( acct_name, acct_name, result ); | |
end if; | |
select * from tbl_account where tbl_account.acct_name = acct_name; | |
END// | |
DELIMITER ; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
* | |
* generated by PacketCompiler. | |
* do not modify this. | |
* | |
* time: 2015-05-27 01:02:11.893 | |
* | |
*/ | |
using System; | |
using System.Diagnostics; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace T_ms_db { | |
/// start of RawCode | |
/// endof RawCode | |
/// class Util | |
/// <summary> | |
/// | |
/// </summary> | |
public class Util | |
{ | |
public const UInt64 VERSION = 0x0000000000000001; // 1 | |
public const UInt64 BUILD_VERSION = 0x01d097cd5382b830; // 130771297318910000 | |
public const UInt64 SALT_UINT64 = 0x7f2774fe16ce03a6; | |
public static byte[] COMPILE_TIME_PASS_BYTES = new byte[] { 0x6d,0x6f,0x89,0x3b,0xdb,0x64,0xa5,0x52,0xf5,0x53,0x2f,0x18,0x70,0x3a,0x90,0x70,0x76,0x7a,0x27,0x0f,0x58,0x54,0xa9,0x6b,0xfd,0x5e,0x59,0x4f,0xab,0x7c,0x33,0x21,0x11,0x77,0x41,0x10,0xc7,0x04,0xa8,0x75,0x97,0x4b,0x41,0x54,0x50,0x4e,0xac,0x49,0xf3,0x69,0x3c,0x25,0x75,0x65,0x3f,0x3b,0x70,0x70,0x60,0x7f,0x75,0x10,0x36,0x07 }; // do not modify | |
public delegate void runLater(); | |
public static System.String ReadCString(System.IO.BinaryReader reader) | |
{ | |
List<byte> byteList = new List<byte>(); | |
byte b; | |
while ((b = reader.ReadByte()) != 0) | |
{ | |
byteList.Add(b); | |
} | |
return Encoding.ASCII.GetString(byteList.ToArray()); | |
} | |
public static System.String ReadUnicodeCString(System.IO.BinaryReader reader) | |
{ | |
List<byte> byteList = new List<byte>(); | |
byte b1, b2; | |
while (true) | |
{ | |
if (-1 == reader.PeekChar()) return "[ERR] STREAM_ERROR"; | |
b1 = reader.ReadByte(); | |
if (-1 == reader.PeekChar()) return "[ERR] STREAM_ERROR"; | |
b2 = reader.ReadByte(); | |
if (b1 == 0 && b2 == 0) break; | |
byteList.Add(b1); | |
byteList.Add(b2); | |
} | |
return Encoding.Unicode.GetString(byteList.ToArray()); | |
} | |
// Fixed-Size C-String | |
public static System.String ReadFixedCString(int fixed_size, System.IO.BinaryReader reader) | |
{ | |
List<byte> byteList = new List<byte>(); | |
byte b; | |
for (int i = 0; i < fixed_size; ++i) | |
{ | |
if (-1 == reader.PeekChar()) return "[ERR] STREAM_ERROR"; | |
byteList.Add(reader.ReadByte()); | |
} | |
return Encoding.ASCII.GetString(byteList.ToArray()); | |
} | |
public static System.String ReadFixedUnicodeCString(int fixed_size, System.IO.BinaryReader reader) | |
{ | |
List<byte> byteList = new List<byte>(); | |
for (int i = 0; i < fixed_size; ++i) | |
{ | |
if (-1 == reader.PeekChar()) return "[ERR] STREAM_ERROR"; | |
byteList.Add(reader.ReadByte()); | |
if (-1 == reader.PeekChar()) return "[ERR] STREAM_ERROR"; | |
byteList.Add(reader.ReadByte()); | |
} | |
return Encoding.Unicode.GetString(byteList.ToArray()); | |
} | |
} | |
/// class Header | |
/// <summary> | |
/// | |
/// </summary> | |
public class Header | |
{ | |
public System.UInt16 sizeWhole = 0; | |
public System.UInt16 typeBody = 0; | |
public static byte[] GetBytes( System.UInt16 typeBody, byte[] body = null ) | |
{ | |
System.UInt16 sizeWhole = 4; | |
if (body != null) | |
sizeWhole += (ushort)body.Length; | |
System.IO.MemoryStream stream = new System.IO.MemoryStream(); | |
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); | |
writer.Write(sizeWhole); | |
writer.Write(typeBody); | |
writer.Write(body); | |
return stream.ToArray(); | |
} | |
public bool Read( byte[] data, int size ) | |
{ | |
if (size < 4) return false; | |
System.IO.MemoryStream stream = new System.IO.MemoryStream(data); | |
System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); | |
sizeWhole = reader.ReadUInt16(); | |
typeBody = reader.ReadUInt16(); | |
if (size < sizeWhole) return false; | |
// okay | |
return true; | |
} | |
} | |
// send packet list | |
public enum Send { | |
MD_GET_ACCOUNT_REQ = 4000, | |
} | |
// recv packet list | |
public enum Recv { | |
DM_GET_ACCOUNT_RES = 4500, | |
} | |
/**************************************************************************** | |
* | |
* Packet Classes for Send/Recv | |
*/ | |
public partial class Send_MD_GetAccountReq | |
{ | |
public static System.UInt16 Type = (System.UInt16)Send.MD_GET_ACCOUNT_REQ; | |
public static System.String GetPacketName() { return "MD_GET_ACCOUNT_REQ"; } | |
// public byte[] GetBytes() | |
public String acct_name = null; | |
} | |
public partial class Recv_DM_GetAccountRes | |
{ | |
public static System.UInt16 Type = (System.UInt16)Recv.DM_GET_ACCOUNT_RES; | |
public static System.String GetPacketName() { return "DM_GET_ACCOUNT_RES"; } | |
// public void Read(byte[] data, int size); | |
public UInt32 result; | |
public UInt64 acct_id; | |
public String acct_name = null; | |
public String nickname = null; | |
public UInt64 creation_time; | |
} | |
public enum Result { | |
RESULT_NOT_IMPLEMENTED = -1, | |
RESULT_FALSE = 0, | |
RESULT_TRUE = 1, | |
} | |
/**************************************************************************** | |
* | |
* Handler Interface | |
*/ | |
public interface ITDBToTMSHandler | |
{ | |
Result On_DM_GetAccountRes( Recv_DM_GetAccountRes packet ); | |
} | |
/**************************************************************************** | |
* | |
* Handler Adaptor | |
*/ | |
public class ATDBToTMSHandler : ITDBToTMSHandler | |
{ | |
public virtual Result On_DM_GetAccountRes( Recv_DM_GetAccountRes packet ) { return Result.RESULT_NOT_IMPLEMENTED; } | |
public static Result Dispatch ( ITDBToTMSHandler this_, System.UInt16 type, byte[] data, int size ) | |
{ | |
switch ( type ) | |
{ | |
case (System.UInt16)Recv.DM_GET_ACCOUNT_RES: | |
{ | |
Recv_DM_GetAccountRes packet = new Recv_DM_GetAccountRes(); | |
packet.Read(data, size); | |
return this_.On_DM_GetAccountRes(packet); | |
} | |
} | |
return Result.RESULT_FALSE; | |
} | |
} | |
/**************************************************************************** | |
* | |
* Serializer for Send/Recv | |
*/ | |
// C# Send Serializer | |
public partial class Send_MD_GetAccountReq | |
{ | |
public byte[] GetBytes() | |
{ | |
System.IO.MemoryStream stream = new System.IO.MemoryStream(); | |
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); | |
System.IO.MemoryStream tail_stream = new System.IO.MemoryStream(); | |
System.IO.BinaryWriter tail_writer = new System.IO.BinaryWriter(tail_stream); | |
int offset = 0; | |
// String acct_name | |
if ( this.acct_name == null ) this.acct_name = ""; | |
writer.Write( (System.UInt64)offset ); | |
byte[] acct_name_buf = Encoding.ASCII.GetBytes(this.acct_name); | |
tail_writer.Write(acct_name_buf); | |
tail_writer.Write((byte)0); | |
offset += acct_name_buf.Length + 1; | |
if ( offset > 0 ) | |
writer.Write(tail_stream.ToArray()); | |
return stream.ToArray(); | |
} | |
} | |
// C# Recv Serializer | |
public partial class Recv_DM_GetAccountRes | |
{ | |
public void Read(byte[] data, int size) | |
{ | |
System.IO.MemoryStream stream = new System.IO.MemoryStream(data); | |
System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); | |
List<Util.runLater> runLaterList = new List<Util.runLater>(); | |
long begin_offset = 0; | |
// UInt32 result | |
this.result = reader.ReadUInt32(); | |
// UInt64 acct_id | |
this.acct_id = reader.ReadUInt64(); | |
// String acct_name | |
long acct_name_offset = (long)reader.ReadUInt64(); | |
runLaterList.Add(() => { | |
stream.Position = begin_offset + acct_name_offset; | |
this.acct_name = Util.ReadCString(reader); | |
}); | |
// String nickname | |
long nickname_offset = (long)reader.ReadUInt64(); | |
runLaterList.Add(() => { | |
stream.Position = begin_offset + nickname_offset; | |
this.nickname = Util.ReadCString(reader); | |
}); | |
// UInt64 creation_time | |
this.creation_time = reader.ReadUInt64(); | |
// run all runLaters | |
begin_offset = stream.Position; | |
foreach (Util.runLater run in runLaterList) | |
run(); | |
} | |
} | |
} // end of T_ms_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generated by protocol compiler | |
// time : 2015-05-27 01:02:11.891 | |
// do not modify | |
#pragma once | |
#include <cstdint> | |
#pragma warning(push) | |
#pragma warning(disable: 4100) // unreferenced formal parameter | |
namespace T_ms_db { | |
#ifndef ___DEFINE_T_ms_db_COMMON___ | |
#define ___DEFINE_T_ms_db_COMMON___ | |
inline const char* name_A() { return "T_ms_db"; } | |
inline const wchar_t* name_W() { return L"T_ms_db"; }; | |
inline const TCHAR* name() { return _T("T_ms_db"); } | |
const std::uint64_t version = 0x0000000000000001; // 1 | |
const std::uint64_t build_version = 0x01d097cd5382b830; // 130771297318910000 | |
const std::uint64_t compiletime_salt = 0x7f2774fe16ce03a6; | |
const size_t compiletime_pass_bytes_size = 64; | |
const std::uint8_t compiletime_pass_bytes[] = { 0x6d,0x6f,0x89,0x3b,0xdb,0x64,0xa5,0x52,0xf5,0x53,0x2f,0x18,0x70,0x3a,0x90,0x70,0x76,0x7a,0x27,0x0f,0x58,0x54,0xa9,0x6b,0xfd,0x5e,0x59,0x4f,0xab,0x7c,0x33,0x21,0x11,0x77,0x41,0x10,0xc7,0x04,0xa8,0x75,0x97,0x4b,0x41,0x54,0x50,0x4e,0xac,0x49,0xf3,0x69,0x3c,0x25,0x75,0x65,0x3f,0x3b,0x70,0x70,0x60,0x7f,0x75,0x10,0x36,0x07 }; | |
/// start of RawCode | |
/// endof RawCode | |
#ifndef _DEFINED_PACKET_RESULT_TYPE | |
#define _DEFINED_PACKET_RESULT_TYPE | |
enum { | |
PACKET_UNKNOWN_PACKET = -4, | |
PACKET_NOT_ENOUGH_MEMORY = -3, | |
PACKET_PARSING_ERROR = -2, | |
PACKET_NOT_IMPLEMENTED = -1, | |
PACKET_FALSE = 0, | |
PACKET_TRUE = 1, | |
}; | |
#endif//_DEFINED_PACKET_RESULT_TYPE | |
#endif//___DEFINE_T_ms_db_COMMON___ | |
#ifndef ___DEFINE_T_ms_db_COMMON_ERROR_CODE__ | |
#define ___DEFINE_T_ms_db_COMMON_ERROR_CODE__ | |
template <typename E> | |
inline auto Enum_AsInt(E const value) | |
-> typename std::underlying_type<E>::type { | |
return static_cast<typename std::underlying_type<E>::type>(value); | |
} | |
enum class Error : std::int32_t { | |
SUCCESS = 0, | |
ERR_NOT_IMPLEMENTED = 1, | |
ERR_GENERAL = 2, | |
ERR_DB_SERVER = 4, | |
ERR_RESOURCE_NOT_FOUND = 300, | |
}; | |
// Error_AsStr | |
inline const char* Error_AsStrA(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return "SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return "ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return "ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return "ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return "ERR_RESOURCE_NOT_FOUND"; | |
} | |
return "Error::UNDEFINED"; | |
} | |
inline const wchar_t* Error_AsStrW(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return L"SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return L"ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return L"ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return L"ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return L"ERR_RESOURCE_NOT_FOUND"; | |
} | |
return L"Error::UNDEFINED"; | |
} | |
template < typename CharType > | |
inline const CharType* T_Error_AsStr(Error r); | |
template <> | |
inline const char* T_Error_AsStr(Error r) { return Error_AsStrA(r); } | |
template <> | |
inline const wchar_t* T_Error_AsStr(Error r) { return Error_AsStrW(r); } | |
inline const TCHAR* Error_AsStr(Error r) { return T_Error_AsStr<TCHAR>(r); } | |
// Error_AsDesc | |
inline const char* Error_AsDescA(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return "SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return "ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return "ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return "ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return "ERR_RESOURCE_NOT_FOUND"; | |
} | |
return "Error::UNDEFINED"; | |
} | |
inline const wchar_t* Error_AsDescW(Error r) { | |
switch (r) { | |
case Error::SUCCESS: return L"SUCCESS"; | |
case Error::ERR_NOT_IMPLEMENTED: return L"ERR_NOT_IMPLEMENTED"; | |
case Error::ERR_GENERAL: return L"ERR_GENERAL"; | |
case Error::ERR_DB_SERVER: return L"ERR_DB_SERVER"; | |
case Error::ERR_RESOURCE_NOT_FOUND: return L"ERR_RESOURCE_NOT_FOUND"; | |
} | |
return L"Error::UNDEFINED"; | |
} | |
template < typename CharType > | |
inline const CharType* T_Error_AsDesc(Error r); | |
template <> | |
inline const char* T_Error_AsDesc(Error r) { return Error_AsDescA(r); } | |
template <> | |
inline const wchar_t* T_Error_AsDesc(Error r) { return Error_AsDescW(r); } | |
inline const TCHAR* Error_AsDesc(Error r) { return T_Error_AsDesc<TCHAR>(r); } | |
#endif//___DEFINE_T_ms_db_COMMON_ERROR_CODE__ | |
#ifndef __PACKET_ID_TMS_TDB | |
#define __PACKET_ID_TMS_TDB | |
// TMS -> TDB | |
enum | |
{ | |
MD_GET_ACCOUNT_REQ = 4000, | |
}; | |
#endif//__PACKET_ID_TMS_TDB | |
#ifndef __PACKET_ID_TDB_TMS | |
#define __PACKET_ID_TDB_TMS | |
// TDB -> TMS | |
enum | |
{ | |
DM_GET_ACCOUNT_RES = 4500, | |
}; | |
#endif//__PACKET_ID_TDB_TMS | |
// FORWARD DECLARATIONS for structs | |
struct Recv_DM_GetAccountRes; | |
// FORWARD DECLARATIONS for structs | |
struct Send_MD_GetAccountReq; | |
#pragma pack(push, 1) | |
struct Send_MD_GetAccountReq | |
{ | |
enum { TYPE = MD_GET_ACCOUNT_REQ }; | |
static const char* GetPacketName() { return "MD_GET_ACCOUNT_REQ"; }; | |
static const wchar_t* GetPacketNameW() { return L"MD_GET_ACCOUNT_REQ"; }; | |
size_t GetSize(); | |
size_t Write(size_t outLen); | |
union { std::uint64_t acct_name_i64; const char *acct_name; }; | |
}; | |
#pragma pack(pop) | |
#pragma pack(push, 1) | |
struct Recv_DM_GetAccountRes | |
{ | |
enum { TYPE = DM_GET_ACCOUNT_RES }; | |
static const char* GetPacketName() { return "DM_GET_ACCOUNT_RES"; }; | |
static const wchar_t* GetPacketNameW() { return L"DM_GET_ACCOUNT_RES"; }; | |
void Read(const char *in, size_t inLen); | |
std::uint32_t result; | |
std::uint64_t acct_id; | |
union { std::uint64_t acct_name_i64; const char *acct_name; }; | |
union { std::uint64_t nickname_i64; const char *nickname; }; | |
std::uint64_t creation_time; | |
}; | |
#pragma pack(pop) | |
class ITDBToTMSHandler | |
{ | |
public: | |
enum { | |
RESULT_NOT_IMPLEMENTED = -1, | |
RESULT_FALSE = 0, | |
RESULT_TRUE = 1, | |
}; | |
// following typedef ensure some constants should be same. | |
typedef char _compile_time_assert_packet_not_implemented[ (PACKET_NOT_IMPLEMENTED == RESULT_NOT_IMPLEMENTED) ? 1 : -1 ]; | |
typedef char _compile_time_assert_packet_false[ (PACKET_FALSE == RESULT_FALSE) ? 1 : -1 ]; | |
typedef char _compile_time_assert_packet_true[ (PACKET_TRUE == RESULT_TRUE) ? 1 : -1 ]; | |
virtual int On_DM_GetAccountRes(const Recv_DM_GetAccountRes *packet) { return RESULT_NOT_IMPLEMENTED; } | |
}; | |
}; // T_ms_db | |
#pragma warning(pop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment