43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { Texts } from "../library/Texts";
|
|
import { VariationDefinitions } from "./VariationTemplates";
|
|
|
|
export type MemberDefinitions = { [index:string]:any };
|
|
export class CppDefinition
|
|
{
|
|
variations:string|VariationDefinitions;
|
|
|
|
class:string;
|
|
|
|
includes:string[];
|
|
forwards:string[];
|
|
|
|
public:MemberDefinitions;
|
|
protected:MemberDefinitions;
|
|
|
|
static createVariation( cppDefinition:CppDefinition, map:Map<string,string> ):CppDefinition
|
|
{
|
|
let variation = new CppDefinition();
|
|
|
|
variation.class = Texts.replaceAll( cppDefinition.class, map );
|
|
|
|
variation.includes = Texts.replaceAllIn( cppDefinition.includes, map );
|
|
variation.forwards = Texts.replaceAllIn( cppDefinition.forwards, map );
|
|
|
|
variation.public = CppDefinition.applyVariationOnAll( cppDefinition.public, map );
|
|
variation.protected = CppDefinition.applyVariationOnAll( cppDefinition.protected, map );
|
|
|
|
return variation;
|
|
}
|
|
|
|
static applyVariationOnAll<T>( obj:T, map:Map<string,string> ):T
|
|
{
|
|
if ( obj === null || obj === undefined )
|
|
{
|
|
return obj;
|
|
}
|
|
|
|
let jsonValue = JSON.stringify( obj );
|
|
jsonValue = Texts.replaceAll( jsonValue, map );
|
|
return JSON.parse( jsonValue ) as T;
|
|
}
|
|
} |