Skip to content

Commit

Permalink
folder reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
Zal0 committed Jan 3, 2020
1 parent c9f89f6 commit 8beb86a
Show file tree
Hide file tree
Showing 10 changed files with 1,210 additions and 1,213 deletions.
20 changes: 11 additions & 9 deletions Reflectpp.vcxproj
Expand Up @@ -88,6 +88,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./Reflectpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -116,6 +117,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./Reflectpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -142,17 +144,17 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ReflectEnumDecl.h" />
<ClInclude Include="ReflectionJsonTools.h" />
<ClInclude Include="ReflectDecl.h" />
<ClInclude Include="Reflection.h" />
<ClInclude Include="ReflectConfig.h" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="Reflectpp\ReflectConfig\ReflectConfig.cpp" />
<ClCompile Include="Reflectpp\Reflection.cpp" />
<ClCompile Include="Reflectpp\ReflectionJsonTools.cpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ReflectionJsonTools.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="Reflection.cpp" />
<ClCompile Include="ReflectConfig.cpp" />
<ClInclude Include="Reflectpp\ReflectConfig\ReflectConfig.h" />
<ClInclude Include="Reflectpp\ReflectDecl.h" />
<ClInclude Include="Reflectpp\ReflectEnumDecl.h" />
<ClInclude Include="Reflectpp\Reflection.h" />
<ClInclude Include="Reflectpp\ReflectionJsonTools.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
51 changes: 23 additions & 28 deletions Reflectpp.vcxproj.filters
Expand Up @@ -5,44 +5,39 @@
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
<Filter Include="Config">
<UniqueIdentifier>{fab3b458-6aa1-49da-938e-676ac7195f03}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Reflection.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ReflectDecl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ReflectionJsonTools.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ReflectEnumDecl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ReflectConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Reflection.cpp">
<ClCompile Include="Reflectpp\Reflection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ReflectionJsonTools.cpp">
<ClCompile Include="Reflectpp\ReflectionJsonTools.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ReflectConfig.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="Reflectpp\ReflectConfig\ReflectConfig.cpp">
<Filter>Config</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Reflectpp\ReflectDecl.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="Reflectpp\ReflectEnumDecl.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="Reflectpp\Reflection.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="Reflectpp\ReflectionJsonTools.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="Reflectpp\ReflectConfig\ReflectConfig.h">
<Filter>Config</Filter>
</ClInclude>
</ItemGroup>
</Project>
136 changes: 68 additions & 68 deletions ReflectConfig.cpp → Reflectpp/ReflectConfig/ReflectConfig.cpp
@@ -1,69 +1,69 @@
#include "ReflectConfig.h"
#include "Reflection.h"

#define DEF_INFO(TYPE, RTYPE) static TypeReflectInfo t_info(RTYPE, sizeof(TYPE), 0); return &t_info;

TypeReflectInfo* GetTypeReflectInfo(bool*) {DEF_INFO(bool, Reflectpp::REFLECT_TYPE_BOOL)}
TypeReflectInfo* GetTypeReflectInfo(char*) {DEF_INFO(char, Reflectpp::REFLECT_TYPE_CHAR)}
TypeReflectInfo* GetTypeReflectInfo(unsigned char*) {DEF_INFO(unsigned char, Reflectpp::REFLECT_TYPE_UCHAR)}
TypeReflectInfo* GetTypeReflectInfo(short*) {DEF_INFO(short, Reflectpp::REFLECT_TYPE_SHORT)}
TypeReflectInfo* GetTypeReflectInfo(unsigned short*) {DEF_INFO(unsigned short, Reflectpp::REFLECT_TYPE_USHORT)}
TypeReflectInfo* GetTypeReflectInfo(int*) {DEF_INFO(int, Reflectpp::REFLECT_TYPE_INT)}
TypeReflectInfo* GetTypeReflectInfo(unsigned int*) {DEF_INFO(unsigned int, Reflectpp::REFLECT_TYPE_UINT)}
TypeReflectInfo* GetTypeReflectInfo(long*) {DEF_INFO(long, Reflectpp::REFLECT_TYPE_LONG)}
TypeReflectInfo* GetTypeReflectInfo(unsigned long*) {DEF_INFO(unsigned long, Reflectpp::REFLECT_TYPE_ULONG)}
TypeReflectInfo* GetTypeReflectInfo(long long*) {DEF_INFO(long long, Reflectpp::REFLECT_TYPE_LONGLONG)}
TypeReflectInfo* GetTypeReflectInfo(unsigned long long*) {DEF_INFO(unsigned long long, Reflectpp::REFLECT_TYPE_ULONGLONG)}
TypeReflectInfo* GetTypeReflectInfo(float*) {DEF_INFO(float, Reflectpp::REFLECT_TYPE_FLOAT)}
TypeReflectInfo* GetTypeReflectInfo(double*) {DEF_INFO(double, Reflectpp::REFLECT_TYPE_DOUBLE)}
TypeReflectInfo* GetTypeReflectInfo(STRING*) {DEF_INFO(STRING, Reflectpp::REFLECT_TYPE_STRING)}

void FromString(ReflectField& field, const Reflectpp::Type reflect_type, const char* str)
{
switch(reflect_type)
{
case Reflectpp::REFLECT_TYPE_BOOL: field.Set< bool > (str[0] == '0' ? false : true); break;
case Reflectpp::REFLECT_TYPE_CHAR: field.Set< char > ((char)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_UCHAR: field.Set< unsigned char > ((unsigned char)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_SHORT: field.Set< short > ((short)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_USHORT: field.Set< unsigned short > ((unsigned short)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_INT: field.Set< int > ((int)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_UINT: field.Set< unsigned int > ((unsigned int)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_LONG: field.Set< long > ((long)atol(str)); break;
case Reflectpp::REFLECT_TYPE_ULONG: field.Set< unsigned long > ((unsigned long)atol(str)); break;
case Reflectpp::REFLECT_TYPE_LONGLONG: field.Set< long long > ((long long)atoll(str)); break;
case Reflectpp::REFLECT_TYPE_ULONGLONG: field.Set< unsigned long long >((unsigned long long)atoll(str)); break;
case Reflectpp::REFLECT_TYPE_FLOAT: field.Set< float > ((float)atof(str)); break;
case Reflectpp::REFLECT_TYPE_DOUBLE: field.Set< double > ((double)atof(str)); break;
case Reflectpp::REFLECT_TYPE_STRING: field.Set< STRING > (str); break;
default: break;
}
}

#define TO_STRING(STR, TYPE) snprintf(buff, BUFF_SIZE, STR, field.Get< TYPE >());
STRING ToString(const ReflectField& field, const Reflectpp::Type reflect_type)
{
static const int BUFF_SIZE = 50;
static char buff[BUFF_SIZE];

switch(reflect_type)
{
case Reflectpp::REFLECT_TYPE_BOOL: TO_STRING("%d", bool); break;
case Reflectpp::REFLECT_TYPE_CHAR: TO_STRING("%c", char); break;
case Reflectpp::REFLECT_TYPE_UCHAR: TO_STRING("%u", unsigned char); break;
case Reflectpp::REFLECT_TYPE_SHORT: TO_STRING("%hd", short); break;
case Reflectpp::REFLECT_TYPE_USHORT: TO_STRING("%hu", unsigned short); break;
case Reflectpp::REFLECT_TYPE_INT: TO_STRING("%d", int); break;
case Reflectpp::REFLECT_TYPE_UINT: TO_STRING("%u", unsigned int); break;
case Reflectpp::REFLECT_TYPE_LONG: TO_STRING("%ld", long); break;
case Reflectpp::REFLECT_TYPE_ULONG: TO_STRING("%lu", unsigned long); break;
case Reflectpp::REFLECT_TYPE_LONGLONG: TO_STRING("%lld", long long); break;
case Reflectpp::REFLECT_TYPE_ULONGLONG: TO_STRING("%llu", unsigned long long); break;
case Reflectpp::REFLECT_TYPE_FLOAT: TO_STRING("%g", float); break;
case Reflectpp::REFLECT_TYPE_DOUBLE: TO_STRING("%g", double); break;
case Reflectpp::REFLECT_TYPE_STRING: return field.Get< STRING >();
default: break;
}

return STRING(buff);
#include "ReflectConfig/ReflectConfig.h"
#include "Reflection.h"

#define DEF_INFO(TYPE, RTYPE) static TypeReflectInfo t_info(RTYPE, sizeof(TYPE), 0); return &t_info;

TypeReflectInfo* GetTypeReflectInfo(bool*) {DEF_INFO(bool, Reflectpp::REFLECT_TYPE_BOOL)}
TypeReflectInfo* GetTypeReflectInfo(char*) {DEF_INFO(char, Reflectpp::REFLECT_TYPE_CHAR)}
TypeReflectInfo* GetTypeReflectInfo(unsigned char*) {DEF_INFO(unsigned char, Reflectpp::REFLECT_TYPE_UCHAR)}
TypeReflectInfo* GetTypeReflectInfo(short*) {DEF_INFO(short, Reflectpp::REFLECT_TYPE_SHORT)}
TypeReflectInfo* GetTypeReflectInfo(unsigned short*) {DEF_INFO(unsigned short, Reflectpp::REFLECT_TYPE_USHORT)}
TypeReflectInfo* GetTypeReflectInfo(int*) {DEF_INFO(int, Reflectpp::REFLECT_TYPE_INT)}
TypeReflectInfo* GetTypeReflectInfo(unsigned int*) {DEF_INFO(unsigned int, Reflectpp::REFLECT_TYPE_UINT)}
TypeReflectInfo* GetTypeReflectInfo(long*) {DEF_INFO(long, Reflectpp::REFLECT_TYPE_LONG)}
TypeReflectInfo* GetTypeReflectInfo(unsigned long*) {DEF_INFO(unsigned long, Reflectpp::REFLECT_TYPE_ULONG)}
TypeReflectInfo* GetTypeReflectInfo(long long*) {DEF_INFO(long long, Reflectpp::REFLECT_TYPE_LONGLONG)}
TypeReflectInfo* GetTypeReflectInfo(unsigned long long*) {DEF_INFO(unsigned long long, Reflectpp::REFLECT_TYPE_ULONGLONG)}
TypeReflectInfo* GetTypeReflectInfo(float*) {DEF_INFO(float, Reflectpp::REFLECT_TYPE_FLOAT)}
TypeReflectInfo* GetTypeReflectInfo(double*) {DEF_INFO(double, Reflectpp::REFLECT_TYPE_DOUBLE)}
TypeReflectInfo* GetTypeReflectInfo(STRING*) {DEF_INFO(STRING, Reflectpp::REFLECT_TYPE_STRING)}

void FromString(ReflectField& field, const Reflectpp::Type reflect_type, const char* str)
{
switch(reflect_type)
{
case Reflectpp::REFLECT_TYPE_BOOL: field.Set< bool > (str[0] == '0' ? false : true); break;
case Reflectpp::REFLECT_TYPE_CHAR: field.Set< char > ((char)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_UCHAR: field.Set< unsigned char > ((unsigned char)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_SHORT: field.Set< short > ((short)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_USHORT: field.Set< unsigned short > ((unsigned short)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_INT: field.Set< int > ((int)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_UINT: field.Set< unsigned int > ((unsigned int)atoi(str)); break;
case Reflectpp::REFLECT_TYPE_LONG: field.Set< long > ((long)atol(str)); break;
case Reflectpp::REFLECT_TYPE_ULONG: field.Set< unsigned long > ((unsigned long)atol(str)); break;
case Reflectpp::REFLECT_TYPE_LONGLONG: field.Set< long long > ((long long)atoll(str)); break;
case Reflectpp::REFLECT_TYPE_ULONGLONG: field.Set< unsigned long long >((unsigned long long)atoll(str)); break;
case Reflectpp::REFLECT_TYPE_FLOAT: field.Set< float > ((float)atof(str)); break;
case Reflectpp::REFLECT_TYPE_DOUBLE: field.Set< double > ((double)atof(str)); break;
case Reflectpp::REFLECT_TYPE_STRING: field.Set< STRING > (str); break;
default: break;
}
}

#define TO_STRING(STR, TYPE) snprintf(buff, BUFF_SIZE, STR, field.Get< TYPE >());
STRING ToString(const ReflectField& field, const Reflectpp::Type reflect_type)
{
static const int BUFF_SIZE = 50;
static char buff[BUFF_SIZE];

switch(reflect_type)
{
case Reflectpp::REFLECT_TYPE_BOOL: TO_STRING("%d", bool); break;
case Reflectpp::REFLECT_TYPE_CHAR: TO_STRING("%c", char); break;
case Reflectpp::REFLECT_TYPE_UCHAR: TO_STRING("%u", unsigned char); break;
case Reflectpp::REFLECT_TYPE_SHORT: TO_STRING("%hd", short); break;
case Reflectpp::REFLECT_TYPE_USHORT: TO_STRING("%hu", unsigned short); break;
case Reflectpp::REFLECT_TYPE_INT: TO_STRING("%d", int); break;
case Reflectpp::REFLECT_TYPE_UINT: TO_STRING("%u", unsigned int); break;
case Reflectpp::REFLECT_TYPE_LONG: TO_STRING("%ld", long); break;
case Reflectpp::REFLECT_TYPE_ULONG: TO_STRING("%lu", unsigned long); break;
case Reflectpp::REFLECT_TYPE_LONGLONG: TO_STRING("%lld", long long); break;
case Reflectpp::REFLECT_TYPE_ULONGLONG: TO_STRING("%llu", unsigned long long); break;
case Reflectpp::REFLECT_TYPE_FLOAT: TO_STRING("%g", float); break;
case Reflectpp::REFLECT_TYPE_DOUBLE: TO_STRING("%g", double); break;
case Reflectpp::REFLECT_TYPE_STRING: return field.Get< STRING >();
default: break;
}

return STRING(buff);
}

0 comments on commit 8beb86a

Please sign in to comment.