{"id":7511,"date":"2021-10-26T11:03:55","date_gmt":"2021-10-26T18:03:55","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7511"},"modified":"2021-10-26T13:09:59","modified_gmt":"2021-10-26T20:09:59","slug":"refactorscript-data-model","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/refactorscript\/datamodel\/","title":{"rendered":"RefactorScript &#8211; Data Model"},"content":{"rendered":"<p>This page describes the data model used by RefactorScript. Each C\/C++ entity (e.g. a class or a function) is represented by a single RefactorScript object of one of the types shown below:<\/p>\n<ul>\n<li><a href=\"#Entity\">Entity<\/a>\n<ul>\n<li><a href=\"#Typedef\">Typedef<\/a><\/li>\n<li><a href=\"#Enum\">Enum<\/a><\/li>\n<li><a href=\"#Record\">Record<\/a><\/li>\n<li><a href=\"#Value\">Value<\/a><\/li>\n<li><a href=\"#Variable\">Variable<\/a>\n<ul>\n<li><a href=\"#Field\">Field<\/a><\/li>\n<li><a href=\"#FunctionArgument\">FunctionArgument<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#Function\">Function<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#TypeRef\">TypeRef<\/a>\n<ul>\n<li><a href=\"#FunctionPrototype\">FunctionPrototype<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#ResolvedType\">ResolvedType<\/a><\/li>\n<li><a href=\"#Base\">Base<\/a><\/li>\n<\/ul>\n<p>RefactorScript objects automatically inherit properties from the base object types. E.g. an instance of the <strong>Field<\/strong> type will inherit all properties of <strong>Variable<\/strong> and <strong>Entity<\/strong>. You can check whether the object belongs to a particular type using the &#8220;is&#8221; operator, e.g.:<\/p>\n<pre class=\"\">if (obj is Function)\r\n{\r\n    \/\/...\r\n}<\/pre>\n<p>The properties of all object types are described below:<\/p>\n<h2><a id=\"Entity\"><\/a>Entity<\/h2>\n<p>Entity is a base type for all C\/C++ entities (e.g. classes, functions, variables, etc.). It always defines the properties shown below:<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>QualifiedName<\/td>\n<td>string<\/td>\n<td>Specifies the fully qualified name of the entity (e.g. <strong>std::string::c_str<\/strong>)<\/td>\n<\/tr>\n<tr>\n<td>ShortName<\/td>\n<td>string<\/td>\n<td>Specifies the name of the entity without its cope (e.g. <strong>c_str<\/strong>)<\/td>\n<\/tr>\n<tr>\n<td>Location<\/td>\n<td>CodeLocation<\/td>\n<td>Specifies the location in the source file where the entity is defined or declared<\/td>\n<\/tr>\n<tr>\n<td>Range<\/td>\n<td>CodeRange<\/td>\n<td>Refers to the part of the source file containing the entity<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Typedef\"><\/a>Typedef<\/h2>\n<p>The <strong>Typedef<\/strong> object represents a single C\/C++ typedef. It inherits the <strong>Entity<\/strong> and <a href=\"#TypeRef\"><strong>TypeRef <\/strong><\/a>types and does not define any additional properties on top of them.<\/p>\n<h2><a id=\"Enum\"><\/a>Enum<\/h2>\n<p>The <strong>Enum<\/strong> object represents a single enum declaration. It inherits the <strong>Entity<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>IsScoped<\/td>\n<td>bool<\/td>\n<td>Specifies whether it&#8217;s a scoped &#8220;enum class&#8221; declaration.<\/td>\n<\/tr>\n<tr>\n<td>UnderlyingType<\/td>\n<td>TypeRef<\/td>\n<td>Specifies the underlying type of the enum (normally &#8220;int&#8221;)<\/td>\n<\/tr>\n<tr>\n<td>Values<\/td>\n<td>Value[]<\/td>\n<td>Specifies all enum values as defined in the declaration<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Record\"><\/a>Record<\/h2>\n<p>The <strong>Record<\/strong> object represents a single struct\/class\/union declaration. It inherits the <strong>Entity<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 38.5787%;\">Property<\/td>\n<td style=\"width: 22.4075%;\">Type<\/td>\n<td style=\"width: 38.9413%;\">Meaning<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">IsClass<\/td>\n<td style=\"width: 22.4075%;\">bool<\/td>\n<td style=\"width: 38.9413%;\">Specifies whether this is a <strong>class<\/strong> declaration<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">IsStruct<\/td>\n<td style=\"width: 22.4075%;\">bool<\/td>\n<td style=\"width: 38.9413%;\">Specifies whether this is a <strong>struct <\/strong>declaration<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">IsUnion<\/td>\n<td style=\"width: 22.4075%;\">bool<\/td>\n<td style=\"width: 38.9413%;\">Specifies whether this is a <strong>union<\/strong> declaration<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">Bases<\/td>\n<td style=\"width: 22.4075%;\">Base[]<\/td>\n<td style=\"width: 38.9413%;\">Contains the list of base classes of a C++ class\/struct<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">Fields<\/td>\n<td style=\"width: 22.4075%;\">Field[]<\/td>\n<td style=\"width: 38.9413%;\">Contains the list of all fields of a record (but not from the base classes)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 38.5787%;\">Methods<\/td>\n<td style=\"width: 22.4075%;\">Function[]<\/td>\n<td style=\"width: 38.9413%;\">Contains the list of all methods of a class (but not from the base classes)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Value\"><\/a>Value<\/h2>\n<p>The <strong>Value<\/strong> object represents a single enum constant. It inherits the <strong>Entity<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 48px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">Property<\/td>\n<td style=\"height: 24px;\">Type<\/td>\n<td style=\"height: 24px;\">Meaning<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">HasValue<\/td>\n<td style=\"height: 24px;\">bool<\/td>\n<td style=\"height: 24px;\">Specifies whether the integral value of the enum constant is known (even if not set explicitly).<\/td>\n<\/tr>\n<tr>\n<td>Value<\/td>\n<td>int<\/td>\n<td>Specifies the exact integral value of the enum constant.<\/td>\n<\/tr>\n<tr>\n<td>HasInitializer<\/td>\n<td>bool<\/td>\n<td>Specifies whether the value of the enum constant was explicitly set via the &#8216;=&#8217; operator.<\/td>\n<\/tr>\n<tr>\n<td>Initializer<\/td>\n<td>SourceRange<\/td>\n<td>Refers to the part of the source file defining the value of the enum constant.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Variable\"><\/a>Variable<\/h2>\n<p>The <strong>Variable<\/strong> object represents a single variable (see also <strong>Field<\/strong> and <strong>FunctionArgument<\/strong>). It inherits the <strong>Entity<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>Type<\/td>\n<td>TypeRef<\/td>\n<td>Specifies the type of the variable.<\/td>\n<\/tr>\n<tr>\n<td>HasInitializer<\/td>\n<td>bool<\/td>\n<td>Specifies whether the variable is explicitly initialized at declaration using the &#8216;=&#8217; operator.<\/td>\n<\/tr>\n<tr>\n<td>Initializer<\/td>\n<td>bool<\/td>\n<td>Refers to the part of the source file defining the initial value of the variable.<\/td>\n<\/tr>\n<tr>\n<td>IsStatic<\/td>\n<td>bool<\/td>\n<td>Specifies whether it is a static field or a static variable.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Field\"><\/a>Field<\/h2>\n<p>The <strong>Field<\/strong> object represents a single field. It inherits the <strong>Variable<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 72px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">Property<\/td>\n<td style=\"height: 24px;\">Type<\/td>\n<td style=\"height: 24px;\">Meaning<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">Access<\/td>\n<td style=\"height: 24px;\">string<\/td>\n<td style=\"height: 24px;\">Specifies the access class of the field (public\/private\/protected).<\/td>\n<\/tr>\n<tr>\n<td>ContainingType<\/td>\n<td>Record<\/td>\n<td>Specifies the class\/struct\/union containing the field.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"FunctionArgument\"><\/a>FunctionArgument<\/h2>\n<p>The <strong>FunctionArgument<\/strong> object represents a single function argument. It inherits the <strong>Variable<\/strong> type.<\/p>\n<h2><a id=\"Function\"><\/a>Function<\/h2>\n<p>The <strong>Function<\/strong> object represents a single function, method, constructor, destructor or an operator. It inherits from the <strong>Entity<\/strong> type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>ReturnType<\/td>\n<td>TypeRef<\/td>\n<td>Specifies the return type of the function<\/td>\n<\/tr>\n<tr>\n<td>IsInline<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is an inline function\/method<\/td>\n<\/tr>\n<tr>\n<td>IsMethod<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a C++ method, operator, constructor or destructor<\/td>\n<\/tr>\n<tr>\n<td>IsStatic<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a static function\/method<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The following properties are only available with <strong>IsMethod == true<\/strong>:<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>IsVirtual<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a virtual method<\/td>\n<\/tr>\n<tr>\n<td>IsPure<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a pure virtual (i.e. abstract) method<\/td>\n<\/tr>\n<tr>\n<td>IsConst<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a const method<\/td>\n<\/tr>\n<tr>\n<td>IsImplicit<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a compiler-generated constructor, destructor or operator<\/td>\n<\/tr>\n<tr>\n<td>IsDeleted<\/td>\n<td>bool<\/td>\n<td>Specifies whether this method is declared as &#8220;=delete&#8221;;<\/td>\n<\/tr>\n<tr>\n<td>IsDefault<\/td>\n<td>bool<\/td>\n<td>Specifies whether this method is declared as &#8220;=default&#8221;;<\/td>\n<\/tr>\n<tr>\n<td>Access<\/td>\n<td>string<\/td>\n<td>Contains the access class of the method (private\/protected\/public).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"TypeRef\"><\/a>TypeRef<\/h2>\n<p>A <strong>TypeRef<\/strong> object represents a reference to a C\/C++ type. It is typically exposed as a part of the <strong><a href=\"#Typedef\">Typedef<\/a><\/strong> object, or via the <strong>Type<\/strong> property of the <strong><a href=\"#Variable\">Variable<\/a><\/strong> object.<\/p>\n<p>Because C\/C++ types can be referenced via typedefs or preprocessor macros, simply finding out the actual type of the variable might not be always sufficient (e.g. in many cases you would like to use &#8220;<strong>string<\/strong>&#8221; instead of &#8220;<strong>std::basic_string&lt;&#8230;&gt;<\/strong>&#8220;. The <strong>TypeRef<\/strong> object contains multiple levels of information about a type, allowing the scripts to pick what works the best in a particular scenario.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>Literal<\/td>\n<td>SourceRange<\/td>\n<td>Refers to the exact syntax that was used to reference the type in the variable declaration or typedef. It includes the preprocessor macros, spaces before the &#8220;*&#8221; symbol for pointers, etc. It does not include the suffix (e.g. &#8220;[]&#8221; for arrays).<\/td>\n<\/tr>\n<tr>\n<td>LiteralSuffix<\/td>\n<td>SourceRange<\/td>\n<td>Contains the part of the type that follows the variable name. E.g. for &#8220;int array[5]&#8221; LiteralSuffix will resolve to &#8220;[5]&#8221;.<\/td>\n<\/tr>\n<tr>\n<td>Referenced<\/td>\n<td>ResolvedType<\/td>\n<td>Specifies the type of the declaration, without resolving any typedefs, but after substituting preprocessor macros.<\/td>\n<\/tr>\n<tr>\n<td>Resolved<\/td>\n<td>ResolvedType<\/td>\n<td>Specifies the type of the declaration after resolving all typedefs.<\/td>\n<\/tr>\n<tr>\n<td>IsValid<\/td>\n<td>bool<\/td>\n<td>Specifies whether the type reference has been resolved to a valid C\/C++ type.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Typically, the fields of TypeRef should be used as follows:<\/p>\n<ul>\n<li>Use <strong>$decl.Type.Literal<\/strong> to copy the exact syntax that was used by an existing declaration to reference a type.<\/li>\n<li>Use <strong>$decl.Type.Referenced.Name<\/strong> to get the fully qualified type name (with the parent classes or namespaces) useful in generating method implementations.<\/li>\n<li>Check fields of <strong>decl.Type.Resolved<\/strong> to test whether the type is a pointer, array, or another special case.<\/li>\n<\/ul>\n<h2><a id=\"FunctionPrototype\"><\/a>FunctionPrototype<\/h2>\n<p>A <strong>FunctionPrototype<\/strong> object is a special case of <strong>TypeRef<\/strong>. It represents the type of a field or typedef that is declared as a function pointer, e.g.:<\/p>\n<pre class=\"\">struct Foo\r\n{\r\n    int (*bar)(int x, int y, int z);\r\n};<\/pre>\n<p>This allows programmatically generating implementations for function pointer fields.<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 72px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">Property<\/td>\n<td style=\"height: 24px;\">Type<\/td>\n<td style=\"height: 24px;\">Meaning<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">ReturnType<\/td>\n<td style=\"height: 24px;\">TypeRef<\/td>\n<td style=\"height: 24px;\">Specifies the return type of the <strong>Function<\/strong> object.<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"height: 24px;\">Arguments<\/td>\n<td style=\"height: 24px;\">FunctionArgument[]<\/td>\n<td style=\"height: 24px;\">Contains the arguments of the function similar to the <strong>Function<\/strong> object.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"Base\"><\/a>Base<\/h2>\n<p>A <strong>Base<\/strong> object represents a reference to a single base class of a C++ class\/struct.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>Access<\/td>\n<td>string<\/td>\n<td>Contains the access class of the base (private\/protected\/public).<\/td>\n<\/tr>\n<tr>\n<td>IsVirtual<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a virtual base.<\/td>\n<\/tr>\n<tr>\n<td>Type<\/td>\n<td>TypeRef<\/td>\n<td>Specifies the base type. Note that it is an instance of <strong>TypeRef<\/strong> and not <strong>Record<\/strong>. This allows tracking the exact name used in the class declaration, or resolving typedefs if needed.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"ResolvedType\"><\/a>ResolvedType<\/h2>\n<p>A <strong>ResolvedType<\/strong> object represents a single C\/C++ type.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>Property<\/td>\n<td>Type<\/td>\n<td>Meaning<\/td>\n<\/tr>\n<tr>\n<td>IsValid<\/td>\n<td>bool<\/td>\n<td>Specifies whether the type has been resolved to a valid C\/C++ type.<\/td>\n<\/tr>\n<tr>\n<td>Name<\/td>\n<td>bool<\/td>\n<td>Specifies the full name of the type.<\/td>\n<\/tr>\n<tr>\n<td>IsConst<\/td>\n<td>bool<\/td>\n<td>Specifies whether the variable having this type has a &#8216;const&#8217; modifier.<\/td>\n<\/tr>\n<tr>\n<td>IsVolatile<\/td>\n<td>bool<\/td>\n<td>Specifies whether the variable having this type has a &#8216;volatile&#8217; modifier.<\/td>\n<\/tr>\n<tr>\n<td>IsPointerOrReference<\/td>\n<td>bool<\/td>\n<td>Specifies whether this type is a pointer or a reference. Use the <strong>PointerSymbol<\/strong> property to distinguish them.<\/td>\n<\/tr>\n<tr>\n<td>PointerSymbol<\/td>\n<td>string<\/td>\n<td>Contains &#8220;*&#8221;, &#8220;&amp;&#8221; or &#8220;&amp;&amp;&#8221; based on the type of the pointer.<\/td>\n<\/tr>\n<tr>\n<td>IsRecord<\/td>\n<td>bool<\/td>\n<td>Specifies whether this type is a class\/struct\/union.<\/td>\n<\/tr>\n<tr>\n<td>IsBuiltin<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a built-in type like &#8220;int&#8221;.<\/td>\n<\/tr>\n<tr>\n<td>IsTypedef<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is a typedefed type.<\/td>\n<\/tr>\n<tr>\n<td>IsArray<\/td>\n<td>bool<\/td>\n<td>Specifies whether this is an array.<\/td>\n<\/tr>\n<tr>\n<td>ArraySize<\/td>\n<td>int<\/td>\n<td>Specifies the size of array in elements.<\/td>\n<\/tr>\n<tr>\n<td>PointedType<\/td>\n<td>ResolvedType<\/td>\n<td>Specifies the pointed type (also for references, arrays and rvalue references).<\/td>\n<\/tr>\n<tr>\n<td>Declaration<\/td>\n<td>Record\/Typedef<\/td>\n<td>Points to the Record\/Typedef declaration if IsRecord or IsTypedef is true.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>This page describes the data model used by RefactorScript. Each C\/C++ entity (e.g. a class or a function) is represented<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[236,52,238],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7511"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=7511"}],"version-history":[{"count":5,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7511\/revisions"}],"predecessor-version":[{"id":7516,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7511\/revisions\/7516"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}