rtti

What is the best way to serialize Delphi application configuration?

狂风中的少年 提交于 2019-12-03 07:04:26
问题 I will answer this question myself, but feel free to provide your answers if you are faster than me or if you don't like my solution. I just came up with this idea and would like to have some opinions on that. Goal: a configuration class that is readable (like an INI-file) but without having to write (and adapt after a new configuration item has been added) the load and save methods. I want to create a class like TMyConfiguration = class (TConfiguration) ... property ShowFlags : Boolean read

std::any without RTTI, how does it work?

扶醉桌前 提交于 2019-12-03 06:46:11
问题 If I want to use std::any I can use it with RTTI switched off. The following example compiles and runs as expected also with -fno-rtti with gcc. int main() { std::any x; x=9.9; std::cout << std::any_cast<double>(x) << std::endl; } But how std::any stores the type information? As I see, if I call std::any_cast with the "wrong" type I got std::bad_any_cast exception as expected. How is that realized or is this maybe only a gcc feature? I found that boost::any did also not need RTTI, but I found

Using RTTI to determine inheritance graph in C++?

社会主义新天地 提交于 2019-12-03 06:39:04
问题 What, if any, c++ constructs are there for listing the ancestors of a class at runtime? Basically, I have a class which stores a pointer to any object, including possibly a primitive type (somewhat like boost::any , which I don't want to use because I need to retain ownership of my objects). Internally, this pointer is a void* , but the goal of this class is to wrap the void* with runtime type-safety. The assignment operator is templated, so at assignment time I take the typeid() of the

Where are the Delphi Attributes Real World Examples?

非 Y 不嫁゛ 提交于 2019-12-03 05:55:15
I know by TMS Aurelius that we can use the "new" 2010 attributes feature to serialize database table fields into object properties at run-time, for example, and I am not an expert on this deep object oriented schema, so I look into the TMS source code and could not understand how to implement it myself, not for DB, not for XML. So I've looked for all Google's results on Delphi Attributes and all that people post are declaration examples and then stops before even showing their examples in action. Then where are the real world examples of how can we project, declare, code and USE those juiced

When can compiling c++ without RTTI cause problems?

主宰稳场 提交于 2019-12-03 04:04:58
问题 I'm using gcc's -fno-rtti flag to compile my C++ without runtime type information. Assuming I'm not using dynamic_cast<> or typeid() , is there anything that could lead me to later problems? 回答1: Since your question is specific to GCC you should consult carefully the documentation for the version you are using. The documentation for GCC 4.5.2 says the following. Which from my reading would indicate that if you avoid dynamic_cast and typeid, you should be ok. That said, I have no personal

Delphi 2010 RTTI : Explore Enumerations

大憨熊 提交于 2019-12-03 02:13:23
Considering such an enumeration : type TTypeOfData = ( [XmlName('ABC')] todABC, [XmlName('DEF')] todDEF, [XmlName('GHI')] todGHI ); Where XmlName is a custom attribute used to define the serialization string for members of this enumeration. How can I explore the attributes attached to each member of this enumeration ? Attributes associated with elements in enumerations are not currently stored in Win32 RTTI data in the executable. RTTI is already responsible for a fair increase in the size of executables, so some lines had to be drawn somewhere. Attributes in Delphi Win32 are supported on

std::any without RTTI, how does it work?

大憨熊 提交于 2019-12-02 20:24:41
If I want to use std::any I can use it with RTTI switched off. The following example compiles and runs as expected also with -fno-rtti with gcc. int main() { std::any x; x=9.9; std::cout << std::any_cast<double>(x) << std::endl; } But how std::any stores the type information? As I see, if I call std::any_cast with the "wrong" type I got std::bad_any_cast exception as expected. How is that realized or is this maybe only a gcc feature? I found that boost::any did also not need RTTI, but I found also not how that is solved. Does boost::any need RTTI? . Digging into the STL header itself gives me

Using RTTI to determine inheritance graph in C++?

荒凉一梦 提交于 2019-12-02 19:12:25
What, if any, c++ constructs are there for listing the ancestors of a class at runtime? Basically, I have a class which stores a pointer to any object, including possibly a primitive type (somewhat like boost::any , which I don't want to use because I need to retain ownership of my objects). Internally, this pointer is a void* , but the goal of this class is to wrap the void* with runtime type-safety. The assignment operator is templated, so at assignment time I take the typeid() of the incoming pointer and store it. Then when I cast back later, I can check the typeid() of the cast type

How to get the type of the elements in a declared TList

回眸只為那壹抹淺笑 提交于 2019-12-02 18:46:32
问题 I'd like to know if there is a way to get the type of the elements of a declared, but not instantiated, TList. I can capture the class of an object property like this: MyList: TList<TMyObject> read FMyList; MyRTTIProperty: TRttiProperty; NewObject: TObject; PropertyClass: TClass; MyRttiProperty := MyRttiType.GetProperty('MyList'); PropertyClass := MyRTTIProperty.PropertyType.Handle.TypeData.ClassType; // (returns TList<TMyObject>) NewObject := PropertyClass.Create; This way I can instantiate

When can compiling c++ without RTTI cause problems?

陌路散爱 提交于 2019-12-02 17:23:27
I'm using gcc's -fno-rtti flag to compile my C++ without runtime type information. Assuming I'm not using dynamic_cast<> or typeid() , is there anything that could lead me to later problems? Since your question is specific to GCC you should consult carefully the documentation for the version you are using. The documentation for GCC 4.5.2 says the following. Which from my reading would indicate that if you avoid dynamic_cast and typeid, you should be ok. That said, I have no personal experience with -fno-rtti. Perhaps you might like to elaborate on why you are using -fno-rtti. -fno-rtti Disable