@skyrim-platform/jcontainers
Version:
TypeScript library for the JContainers Skyrim modding utility
86 lines (81 loc) • 6.58 kB
TypeScript
import { Form } from "skyrimPlatform";
/** Most call entries made to JC will be logged. Heavy traffic, by default is disabled.
Not thread safe for multiple users (though harmless). */
export declare const enableAPILog: (arg0: boolean) => void;
/** --- Lifetime management functionality.
Read this https://github.com/ryobg/JContainers/wiki/Lifetime-Management before using any of lifetime management functions
Retains and returns the object. */
export declare const retain: (object: number, tag?: string) => number;
/** Releases the object and returns zero, so you can release and nullify with one line of code: object = JValue.release(object) */
export declare const release: (object: number) => number;
/** Just a union of retain-release calls. Releases @previousObject, retains and returns @newObject. */
export declare const releaseAndRetain: (previousObject: number, newObject: number, tag?: string) => number;
/** Releases all objects tagged with @tag.
Internally invokes JValue.release on each object same amount of times it has been retained. */
export declare const releaseObjectsWithTag: (tag: string) => void;
/** Minimizes the time JC temporarily owns the object, returns the object.
By using this function you help JC to delete unused objects as soon as possible.
Has zero effect if the object is being retained or if another object contains/references it. */
export declare const zeroLifetime: (object: number) => number;
/** Handly for temporary objects (objects with no owners) - the pool 'locationName' owns any amount of objects, preventing their destuction, extends lifetime.
Do not forget to clean the pool later! Typical use:
int jTempMap = JValue.addToPool(JMap.object(), "uniquePoolName")
int jKeys = JValue.addToPool(JMap.allKeys(someJMap), "uniquePoolName")
and anywhere later:
JValue.cleanPool("uniquePoolName") */
export declare const addToPool: (object: number, poolName: string) => number;
export declare const cleanPool: (poolName: string) => void;
/** --- Mics. functionality
Returns shallow copy (won't copy child objects) */
export declare const shallowCopy: (object: number) => number;
/** Returns deep copy */
export declare const deepCopy: (object: number) => number;
/** Tests whether given object identifier is not the null object.
Note that many other API functions already check that too. */
export declare const isExists: (object: number) => boolean;
/** Returns true if the object is map, array or formmap container */
export declare const isArray: (object: number) => boolean;
export declare const isMap: (object: number) => boolean;
export declare const isFormMap: (object: number) => boolean;
export declare const isIntegerMap: (object: number) => boolean;
/** Returns true, if the container is empty */
export declare const empty: (object: number) => boolean;
/** Returns amount of items in the container */
export declare const count: (object: number) => number;
/** Removes all items from the container */
export declare const clear: (object: number) => void;
/** JSON serialization/deserialization:
Creates and returns a new container object containing contents of JSON file */
export declare const readFromFile: (filePath: string) => number;
/** Parses JSON files in a directory (non recursive) and returns JMap containing {filename, container-object} pairs.
Note: by default it does not filter files by extension and will try to parse everything */
export declare const readFromDirectory: (directoryPath: string, extension?: string) => number;
/** Creates a new container object using given JSON string-prototype */
export declare const objectFromPrototype: (prototype: string) => number;
/** Writes the object into JSON file */
export declare const writeToFile: (object: number, filePath: string) => void;
/** Returns type of resolved value. 0 - no value, 1 - none, 2 - int, 3 - float, 4 - form, 5 - object, 6 - string */
export declare const solvedValueType: (object: number, path: string) => number;
/** Path resolving:
Returns true, if it's possible to resolve given path, i.e. if it's possible to retrieve the value at the path.
For ex. JValue.hasPath(container, ".player.health") will test whether @container structure close to this one - {'player': {'health': health_value}} */
export declare const hasPath: (object: number, path: string) => boolean;
/** Attempts to retrieve value at given path. If fails, returns @default value */
export declare const solveFlt: (object: number, path: string, defaultVal?: number) => number;
export declare const solveInt: (object: number, path: string, defaultVal?: number) => number;
export declare const solveStr: (object: number, path: string, defaultVal?: string) => string;
export declare const solveObj: (object: number, path: string, defaultVal?: number) => number;
export declare const solveForm: (object: number, path: string, defaultVal?: Form | null | undefined) => Form | null | undefined;
/** Attempts to assign the value. If @createMissingKeys is False it may fail to assign - if no such path exist.
With 'createMissingKeys=true' it creates any missing path element: solveIntSetter(map, ".keyA.keyB", 10, true) on empty JMap creates {keyA: {keyB: 10}} structure */
export declare const solveFltSetter: (object: number, path: string, value: number, createMissingKeys?: boolean) => boolean;
export declare const solveIntSetter: (object: number, path: string, value: number, createMissingKeys?: boolean) => boolean;
export declare const solveStrSetter: (object: number, path: string, value: string, createMissingKeys?: boolean) => boolean;
export declare const solveObjSetter: (object: number, path: string, value: number, createMissingKeys?: boolean) => boolean;
export declare const solveFormSetter: (object: number, path: string, value: Form | null | undefined, createMissingKeys?: boolean) => boolean;
/** Evaluates piece of lua code. Lua support is experimental */
export declare const evalLuaFlt: (object: number, luaCode: string, defaultVal?: number) => number;
export declare const evalLuaInt: (object: number, luaCode: string, defaultVal?: number) => number;
export declare const evalLuaStr: (object: number, luaCode: string, defaultVal?: string) => string;
export declare const evalLuaObj: (object: number, luaCode: string, defaultVal?: number) => number;
export declare const evalLuaForm: (object: number, luaCode: string, defaultVal?: Form | null | undefined) => Form | null | undefined;