快速入门:数据

内容表

概述

Basic Data Types

The MAXON API provides basic data types in an OS-independent way. Basic data types exist in both 32 and 64 bit size (e.g. maxon::Int32 and maxon::Int64 ). maxon::Int is the same as maxon::Int64 .

Primitive Data Types Manual (Classic) and Basic Data Types .

// This example performs some simple mathematical operations with the // basic data types provided by the MAXON API.

// add two values const maxon::Int32 valueA = 123; const maxon::Int32 valueB = 456;

const maxon::Int32 sum = valueA + valueB;

// get ratio const maxon::Int referenceValue = 1000; const maxon::Float ratio = maxon::Float (sum) / maxon::Float (referenceValue);

DiagnosticOutput ( "Ratio: @" , ratio);

There are also special vector and matrix classes. See Vector Manual (Classic) , Matrix Manual (Classic) , Vectors and Matrices .

// This example translates the given position using a newly constructed matrix.

// old position const maxon::Vector pos(100, 100, 100);

// create matrix const maxon::Matrix translate = maxon::GetTranslationMatrix ( 向量 (10));

// apply matrix const maxon::Vector newPos = translate * pos; DiagnosticOutput ( "New Position: @" , newPos);

Strings

The API includes both the classic String maxon::String String class is based on maxon::String .

String Manual (Classic) and String Manual .

// This example performs various string operations. const maxon::String foo { "foo" }; const maxon::String bar { "bar" }; const maxon::String fooBar = foo + " " _s + bar; DiagnosticOutput ( "Text: @" , fooBar); const maxon::String fooBarUppercase = fooBar.ToUpper(); DiagnosticOutput ( "All Caps: @" , fooBarUppercase);

Data Collections

Data can be stored and handled in array, mash maps and lists. These classes allow fast and safe handling of dynamic data.

BaseArray Manual , Arrays Manual and MAXON API Containers & Data Collections .

// This example creates a BaseArray and fills it with some numbers. // The stores values are printed to the console.

// create array maxon::BaseArray<maxon::Int32> numbers;

// insert data into the array numbers. Append (0) iferr_return ; numbers. Append (1) iferr_return ; numbers. Append (1) iferr_return ; numbers. Append (2) iferr_return ; numbers. Append (3) iferr_return ; numbers. Append (5) iferr_return ; numbers. Append (8) iferr_return ;

// check all elements for ( const maxon::Int32 & number : numbers) { DiagnosticOutput ( "Number: @" , number); }

// get specific element const maxon::Int32 number = numbers[0]; DiagnosticOutput ( "Number: @" , number);

Classic Data Containers

The container types GeData and BaseContainer are used to store any kind of classic data type. The typical use case is to store the parameter values of objects that are based on C4DAtom like BaseObject , BaseMaterial etc.

GeData Manual , BaseContainer Manual and C4DAtom Manual .

// This example stores some data in a GeData and BaseContainer object.

// define IDs const ::Int32 VALUE_A = 1; const ::Int32 VALUE_B = 2; ::Int32 value = 123;

// store data in GeData GeData data; data. SetInt32 (value);

// store data in BaseContainer BaseContainer container; container. SetData (VALUE_A, data); container. SetInt32 (VALUE_B, 456);

// access data const ::Int32 firstValue = container. GetInt32 (VALUE_A); DiagnosticOutput ( "First Value: @" , firstValue); const GeData & secondValueData = container. GetData (VALUE_B); const ::Int32 secondValue = secondValueData. GetInt32 (); DiagnosticOutput ( "Second Value: @" , secondValue);

MAXON API Data Containers

The MAXON API equivalent to GeData and BaseContainer are maxon::Data and maxon::DataDictionary. These classes are used to store any kind of MAXON API data type. A maxon::DataDictionary is often used to define settings of a complex operation.

Data Manual and DataDictionary Manual .

// This example stores data in Data and DataDictionary objects.

// define IDs const Int32 VALUE_A = 1; const Int32 VALUE_B = 2; const maxon::Int32 value = 123;

// store data in maxon::Data maxon::Data data; data. Set (value) iferr_return ;

// store data in maxon::DataDictionary maxon::DataDictionary dictionary; dictionary.Set(VALUE_A, data) iferr_return ; dictionary.Set(VALUE_B, maxon::Int32 (456)) iferr_return ;

// acess data const maxon::Int32 firstValue = dictionary.Get< maxon::Int32 >(VALUE_A) iferr_return ; DiagnosticOutput ( "First Value: @" , firstValue); const maxon::Data secondValueData = dictionary. GetData ( maxon::ConstDataPtr (VALUE_B)) iferr_return ; const maxon::Int32 secondValue = secondValueData. Get < maxon::Int32 >() iferr_return ; DiagnosticOutput ( "Second Value: @" , secondValue);

Stream Conversions

maxon::StreamConversionInterface is a generic interface for any kind of data conversion. Examples are data compression, encryption or the calculation of hash values.

Stream Conversions Manual .

// This example calculates the MD5 hash of a given maxon::String using StreamConversions.

// source text const maxon::String text { "Hello World" }; const maxon::BaseArray<maxon::Char> source = text.GetCString() iferr_return ;

// prepare target buffer maxon::BaseArray<maxon::UChar> hash;

// MD5 const maxon::StreamConversionRef md5 = maxon::StreamConversions::HashMD5().Create() iferr_return ; md5.ConvertAll(source, hash) iferr_return ; const maxon::String md5Hash = maxon::GetHashString (hash) iferr_return ; DiagnosticOutput ( "MD5 Hash: @" , md5Hash);

自定义数据类型

Classic custom data types are based on iCustomDataType and CustomDataTypeClass . Such custom data types can be stored in GeData and BaseContainer 对象。

New MAXON API data types are registered using the MAXON_DATATYPE attribute. Such data types can be stored in maxon::Data and maxon:DataDictionary objects.

MAXON Data Type .

BaseContainer::GetData
const GeData & GetData(Int32 id) const
定义: c4d_basecontainer.h:262
BaseContainer::SetData
GeData * SetData(Int32 id, const GeData &n)
定义: c4d_basecontainer.h:255
maxon::Mat3< Vector >
BaseContainer::SetInt32
void SetInt32(Int32 id, Int32 l)
定义: c4d_basecontainer.h:505
maxon::String
定义: string.h:1197
maxon::GetHashString
Result< String > GetHashString(const BaseArray< UChar > &hashValue)
maxon::Data
定义: datatypebase.h:1143
iferr_return
#define iferr_return
定义: resultbase.h:1434
maxon::ConstDataPtr
定义: datatypebase.h:1730
maxon::Data::Get
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
定义: datatypebase.h:1352
maxon::Float
Float64 Float
定义: apibase.h:193
maxon::Data::Set
Result< void > Set(T &&data)
定义: datatypebase.h:1341
maxon::BaseArray
定义: basearray.h:366
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
maxon::GetTranslationMatrix
Mat3< Vec3< FLOAT > > GetTranslationMatrix(const Vec3< FLOAT > &translation)
Calculates a matrix to move / translate.
maxon::BaseArray::Append
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append()
定义: basearray.h:569
maxon::Vec3< Float, 1 >
GeData::GetInt32
Int32 GetInt32(void) const
定义: c4d_gedata.h:427
maxon::Int32
int32_t Int32
32 bit signed integer datatype.
定义: apibase.h:172
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
GeData
定义: c4d_gedata.h:82
GeData::SetInt32
void SetInt32(Int32 v)
定义: c4d_gedata.h:573
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145
BaseContainer::GetInt32
Int32 GetInt32(Int32 id, Int32 preset=0) const
定义: c4d_basecontainer.h:303
BaseContainer
定义: c4d_basecontainer.h:46
GeData::GetData
const maxon::Data & GetData(void) const
定义: c4d_gedata.h:499

Copyright  © 2014-2025 乐数软件    

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