Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  IDL Reference  >  Programming and Control  >  IDL_PRIMITIVE

IDL_PRIMITIVE

IDL_PRIMITIVE

The IDL_PRIMITIVE function creates a new IDL_PRIMITIVE. An IDL_PRIMITIVE is a container for IDL primitive data types including any mixture of scalars, arrays, lists, hashes, and other dictionaries. IDL_PRIMITIVE is typically used with IDLParameterPrimitive to allow an IDLTask that defines a parameter as type PRIMITIVE to preserve the structure of the data to pass through dehydration without modification. IDL Task Engine uses dehydration with json serialization to communicate via stdio. In most cases you want hydration to perserve data types and use of HASH and LIST is recommended. There are some scenarios where the key-value structure is important and you want to use IDL_PRIMITIVE. PRIMITIVE type does not guarentee reversiblity on hydration.

Examples


Create an IDL_PRIMITIVE containing a HASH and access value.

mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
primitive = IDL_PRIMITIVE(mydata)
PRINT, primitive.VALUE

IDL prints:

one:        1.0000000
blue:      255       0       0
Pi:        3.1415926535897931

Compare IDL_PRIMITIVE dehydration vs. HASH dehydration.

mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
primitive = IDL_PRIMITIVE(mydata)
PRINT, primitive.Dehydrate(), /IMPLIED_PRINT

IDL prints:

{
  "one": 1.0000000,
  "blue": [255, 0, 0],
  "Pi": 3.1415926535897931
}

Now try IDL_PRIMITIVE dehydration:

mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
PRINT, mydata.Dehydrate(), /IMPLIED_PRINT

IDL prints:

{
    "fold_case": false,
    "elements": {
      "one": {
      "type": "FLOAT",
      "dehydratedForm": 1.0000000
      },
      "blue": {
      "type": "INT",
      "dehydratedForm": [255, 0, 0]
      },
      "Pi": {
      "type": "DOUBLE",
      "dehydratedForm": 3.1415926535897931
      }
    }
}

Methods

 

Syntax


Result = IDL_Primitive(Value)

Arguments


Value

The value for the IDL_Primitive to contain including any mixture of scalars, arrays, lists, hashes, and other dictionaries.

Keywords


None

Properties


You can retrieve the following properties using either "dot" notation or the ::GetProperty method.

VALUE

This property contains the value IDL_PRIMITIVE contains.


IDL_Primitive::Dehydrate


The IDL_Primitive::Dehydrate method is a pass through of the value it contains.

Examples


mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
primitive = IDL_PRIMITIVE(mydata)
PRINT, primitive.Dehydrate(), /IMPLIED_PRINT

IDL prints:

{
  "one": 1.0000000,
  "blue": [255, 0, 0],
  "Pi": 3.1415926535897931
}

Syntax


Result = IDL_Primitive.Dehydrate( )

Return Value


Returns the value contained by IDL_Primitive.

Arguments


None

Keywords


None


IDL_Primitive::Hydrate


The IDL_Primitive::Hydrate static method takes a value and creates an IDL_Primitive instance.

Examples


Test if HASH is valid for IDL_Primtive.

mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
myprimitive = IDL_Primitive.Hydrate(mydata)
help, myprimitive

IDL prints:

MYPRIMITIVE     OBJREF    = <ObjHeapVar2469(IDL_PRIMITIVE)>

Syntax


Result = IDL_Primitive.Hydrate( Value)

Return Value


Returns an IDL_Primitive instance.

Arguments


Value

The value for the IDL_Primitive to contain.

Keywords


None


IDL_Primitive::IsPrimitive


The IDL_Primitive::IsPrimitive static method is used to validate if the value is a IDL primitive type. It is useful if you do not want to handle a potential error on the creation of an IDL_Primitive.

Examples


Test if HASH is valid for IDL_Primtive.

mydata = HASH("one", 1.0, "blue", [255,0,0], "Pi", !DPI)
PRINT, IDL_Primitive.IsPrimitive(mydata)

IDL prints:

  1

Test if a structure is valid for IDL_Primtive.

mydata = {a:0}
PRINT, IDL_Primitive.IsPrimitive(mydata)

IDL prints:

  0

Syntax


Result = IDL_Primitive.IsPrimitive( Value)

Return Value


Returns a boolean if value is primitive or not.

Arguments


Value

The value to verify if is of a primitive type.

Keywords


None

Version History


8.6

Introduced

See Also


IDLParameterPrimitive, IDLTask, IDL Task Engine



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us