GeData Manual

内容表

关于

GeData is a container class. This container is used to store data of all classic data types that are supported by Cinema 4D .

Access

A GeData object can be used to directly change the value of a parameter of a C4DAtom object:

另请参阅 C4DAtom Manual .

A BaseContainer object stores multiple values using GeData objects:

另请参阅 BaseContainer Manual .

// This example reads the "Radius" parameter of the selected sphere object using GeData.
BaseObject * object = doc-> GetActiveObject ();

// check if the active object is not a "Sphere" object if ( object == nullptr || object-> IsInstanceOf ( Osphere ) == false ) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION );

GeData data;

// access PRIM_SPHERE_RAD parameter if (!object-> GetParameter ( DescID ( PRIM_SPHERE_RAD ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// check if container contains a float value if (data. GetType () != DA_REAL ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius));

数据

类型

A GeData object stores data of a certain type.

// Code like this is typically used in a NodeData::Init() function to make sure complex data types are initialized BaseContainer & bc = (( BaseList2D *)node)->GetDataInstanceRef(); bc. SetData (1234, GeData { DTYPE_BASELISTLINK , DEFAULTVALUE });
注意
If the type is not set, GeData::GetType() returns DA_NIL .
// Using GetType() it is possible to check if the returned value is of the expected type. GeData data; const Bool success = sphere-> GetParameter ( DescID ( PRIM_SPHERE_RAD ), data, DESCFLAGS_GET::NONE ); if (!success) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// check type if (data. GetType () != DA_REAL ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float radius = data. GetFloat ();

Access

The GeData class offers access functions for all supported data types. "Set" functions set the value and also change the data type if needed. "Get" functions return the value and are only allowed to be used if the data type matches.

Int32 and Bool data (data type DA_LONG ):

Int64 data (data type DA_LLONG ):

Float data (data type DA_REAL ):

另请参阅 Primitive Data Types Manual (Classic) .

Void pointers (data type DA_VOID ):

// This example stores a void pointer in a GeData object. GeData data; data. SetVoid (& object );

// ... SomeObject* const obj = static_cast< SomeObject* > (data. GetVoid ());

注意
In general it is not recommended to use "raw" pointers, instead see BaseLink Manual .

Raw memory (data type DA_BYTEARRAY ):

// This example stores some raw memory in a GeData object. GeData geData; geData. SetMemory (memory, memSize); Int count; const Char * const data = ( Char *)geData. GetMemory (count); if (data != nullptr ) { String output; output. SetCString (data, count); ApplicationOutput (output); }

向量 objects (data type DA_VECTOR ):

另请参阅 Vector Manual (Classic) .

矩阵 objects (data type DA_MATRIX ):

另请参阅 Matrix Manual (Classic) .

String objects and C4DUuid objects (data type DA_STRING ):

另请参阅 String Manual (Classic) .

Filename objects (data type DA_FILENAME ):

另请参阅 Filename Manual .

C4DUuid objects: (data type DA_UUID ):

BaseTime objects (data type DA_TIME ):

另请参阅 BaseTime 手册 .

Tristate (data type DA_TRISTATE ):

另请参阅 TriState Manual .

BaseContainer objects (data type DA_CONTAINER ):

// This example stores a BaseContainer in a GeData object. GeData data; MAXON_SCOPE { // store BaseContainer BaseContainer bc; bc. InsData (100, "foobar" ); data. SetContainer (bc); } MAXON_SCOPE { // access stored BaseContainer BaseContainer * bc = data. GetContainer (); if (bc == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Container Content: " + bc-> GetData (100). GetString ()); }

另请参阅 BaseContainer Manual .

BaseLink objects (data type DA_ALIASLINK ):

另请参阅 BaseLink Manual .

Custom data types:

// This example accesses a custom data type value from a GeData object.

// get data GeData data; if (!activeTag->GetParameter( DescLevel ( EXPRESSION_PRIORITY ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// get custom data type value CustomDataType * const customData = data. GetCustomDataType ( CUSTOMGUI_PRIORITY_DATA ); PriorityData * const priorityData = static_cast< PriorityData * > (customData); if (priorityData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// edit data priorityData-> SetPriorityValue ( PRIORITYVALUE_CAMERADEPENDENT , GeData { true }); activeTag->SetParameter( DescLevel ( EXPRESSION_PRIORITY ), data, DESCFLAGS_SET::NONE );

拷贝

The data of one GeData object can easily be copied to another object:

// This example copies the data from one GeData // object to another. GeData stringData { "foobar" }; GeData intData(100); stringData.CopyData(&intData, nullptr );

// check if container contains a String if (intData.GetType() == DA_STRING ) ApplicationOutput ( "Data: " + intData.GetString());

清零

A GeData object can be cleared.

// This example stores a String in the given GeData object just do delete it. GeData data { "foobar" };

// check if container contains a String if (data. GetType () == DA_STRING ) ApplicationOutput ( "data contains a string" _s); data. Free ();

// check if data has no type (data is not set) if (data. GetType () == DA_NIL ) ApplicationOutput ( "data is empty" _s);

比较

Two GeData objects can be compared with the usual operators:

// This example compares two GeData objects with the "same" value but different types. GeData intergerDataA; intergerDataA. SetInt32 (123); GeData integerDataB; integerDataB. SetInt64 (123); if (intergerDataA != integerDataB) ApplicationOutput ( "Data is different" _s);

Disc I/O

A GeData object can be stored in a HyperFile :

// This example writes a GeData value to a HyperFile. AutoAlloc<HyperFile> hf; if (hf == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// open HyperFile to write if (hf-> Open (456, filename, FILEOPEN::WRITE , FILEDIALOG::ANY )) { hf-> WriteGeData (data); hf-> 关闭 (); } else { return maxon::IoError( MAXON_SOURCE_LOCATION , MaxonConvert (filename, MAXONCONVERTMODE::NONE ), "Could not open file." _s); }

// This example reads a GeData value from a HyperFile stored on disc. AutoAlloc<HyperFile> hf; if (hf == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// open HyperFile to read if (hf-> Open (456, filename, FILEOPEN::READ , FILEDIALOG::ANY )) { GeData data; hf-> ReadGeData (&data);

// check if container contains a String if (data. GetType () == DA_STRING ) ApplicationOutput ( "Loaded GeData String: " + data. GetString ()); hf-> 关闭 (); } else { return maxon::IoError( MAXON_SOURCE_LOCATION , MaxonConvert (filename, MAXONCONVERTMODE::NONE ), "Could not open file." _s); }

延伸阅读

BaseContainer::GetData
const GeData & GetData(Int32 id) const
定义: c4d_basecontainer.h:262
EXPRESSION_PRIORITY
@ EXPRESSION_PRIORITY
定义: texpression.h:6
String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
PRIORITYVALUE_CAMERADEPENDENT
#define PRIORITYVALUE_CAMERADEPENDENT
Bool Camera dependent.
定义: customgui_priority.h:36
BaseList2D
定义: c4d_baselist.h:2144
BaseContainer::SetData
GeData * SetData(Int32 id, const GeData &n)
定义: c4d_basecontainer.h:255
Int
maxon::Int Int
定义: ge_sys_math.h:62
BaseObject
定义: c4d_baseobject.h:224
DescID
定义: lib_description.h:327
GeData::GetType
Int32 GetType(void) const
定义: c4d_gedata.h:407
FILEDIALOG::ANY
@ ANY
Show an error dialog for any error.
Float
maxon::Float Float
定义: ge_sys_math.h:64
DA_REAL
@ DA_REAL
Float.
定义: c4d_gedata.h:41
DTYPE_BASELISTLINK
@ DTYPE_BASELISTLINK
BaseLink.
定义: lib_description.h:74
PriorityData::SetPriorityValue
Bool SetPriorityValue(Int32 lValueID, const GeData &data)
DA_NIL
@ DA_NIL
No value.
定义: c4d_gedata.h:38
MAXONCONVERTMODE::NONE
@ NONE
No check if file exists under case-sensitive drives.
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
DESCFLAGS_SET::NONE
@ NONE
None.
PRIM_SPHERE_RAD
@ PRIM_SPHERE_RAD
定义: osphere.h:6
GeData::Free
void Free(void)
Deletes the internal data and sets the type to DA_NIL.
定义: c4d_gedata.h:337
DA_STRING
@ DA_STRING
String.
定义: c4d_gedata.h:47
HyperFile::Open
Bool Open(Int32 ident, const Filename &filename, FILEOPEN mode, FILEDIALOG error_dialog)
MaxonConvert
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
Osphere
#define Osphere
Sphere.
定义: ge_prepass.h:1041
String
定义: c4d_string.h:38
FILEOPEN::WRITE
@ WRITE
GeData::GetVoid
void * GetVoid(void) const
定义: c4d_gedata.h:445
DescLevel
Represents a level within a DescID.
定义: lib_description.h:286
HyperFile::WriteGeData
Bool WriteGeData(const GeData &v)
GeData
定义: c4d_gedata.h:82
GeData::GetMemory
void * GetMemory(Int &count)
定义: c4d_gedata.h:546
GeData::SetInt32
void SetInt32(Int32 v)
定义: c4d_gedata.h:573
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
定义: c4d_gedata.h:65
CustomDataType
Base class for custom data types.
定义: c4d_customdatatype.h:50
GeData::GetString
const String & GetString(void) const
定义: c4d_gedata.h:463
GeData::SetContainer
void SetContainer(const BaseContainer &v)
定义: c4d_gedata.h:645
FILEOPEN::READ
@ READ
Open the file for reading.
HyperFile::ReadGeData
Bool ReadGeData(GeData *v)
HyperFile::Close
Bool Close()
AutoAlloc
定义: ge_autoptr.h:36
DESCFLAGS_GET::NONE
@ NONE
None.
GeData::SetInt64
void SetInt64(const Int64 &v)
定义: c4d_gedata.h:579
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
定义: c4d_gedata.h:507
BaseContainer::InsData
GeData * InsData(Int32 id, const GeData &n)
定义: c4d_basecontainer.h:238
GeData::SetVoid
void SetVoid(void *v)
定义: c4d_gedata.h:585
CUSTOMGUI_PRIORITY_DATA
#define CUSTOMGUI_PRIORITY_DATA
Priority custom data type ID.
定义: customgui_priority.h:23
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
BaseDocument::GetActiveObject
BaseObject * GetActiveObject(void)
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
定义: c4d_baselist.h:1373
GeData::GetContainer
BaseContainer * GetContainer(void) const
定义: c4d_gedata.h:487
Char
maxon::Char Char
定义: ge_sys_math.h:54
String::SetCString
void SetCString(const Char *cstr, Int count=-1, STRINGENCODING type=STRINGENCODING::XBIT)
定义: c4d_string.h:741
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
MAXON_SCOPE
#define MAXON_SCOPE
定义: apibase.h:2645
GeData::SetMemory
void SetMemory(void *data, Int count)
定义: c4d_gedata.h:592
PriorityData
Priority custom data type (CUSTOMGUI_PRIORITY_DATA).
定义: customgui_priority.h:79
BaseContainer
定义: c4d_basecontainer.h:46
GeData::GetFloat
Float GetFloat(void) const
定义: c4d_gedata.h:439

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1