class cmpi::CMPIContext

Public Instance Methods

add_entry(name, CMPIValue, CMPIType) click to toggle source

/*

* Add entry by name
*
void add_entry(const char* name, const CMPIValue* data, 
                     const CMPIType type) {
    CMAddContextEntry($self, name, data, type);
  }

  /*
   * Get entry by name
   * call-seq:
   *   get_entry(name) -> CMPIData
   */
  CMPIData get_entry(const char* name) {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetContextEntry($self, name, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        data.type = CMPI_null;
        data.state = CMPI_notFound;
        data.value.chars = NULL;
    }
    return data;
  }

  /*
   * Get entry by index or name
   * call-seq:
   *   get_entry_at(index) -> [name, CMPIData]
   *   [index] -> [name, CMPIData]
   *
   * returns a name:string,value:CMPIData pair
   */
#if defined (SWIGRUBY)
  %alias get_entry_at "[]";
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV* 
#endif
  __type get_entry_at(
#if defined (SWIGRUBY)
  VALUE pos
#else
  int index
#endif
  )
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data;
    const char *name;
#if defined (SWIGRUBY)
    if (FIXNUM_P(pos)) {
      data = CMGetContextEntryAt($self, FIX2LONG(pos), &s, &st);      
    }
    else {
      name = target_charptr(pos);
      data = CMGetContextEntry($self, name, &st);
    }
#else
    data = CMGetContextEntryAt($self, index, &s, &st);
#endif

    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
    if (s)
      name = CMGetCharPtr(s);
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, PyString_FromString(name));
    PyTuple_SetItem(result, 1, tdata);
#else
    result = Target_SizedArray(2);
    Target_Append(result, Target_String(name));
    Target_Append(result, tdata);
#endif
    TARGET_THREAD_END_BLOCK;
    if (s)
      CMRelease(s);
    return result;
  }

  /*
   * Get number of entries in Context
   */
  CMPICount get_entry_count(void) {
     return CMGetContextEntryCount($self, NULL); 
    // TODO CMPIStatus exception handling
  }

}
get_entry(name) → CMPIData click to toggle source

/*

* Get entry by name
*
CMPIData get_entry(const char* name) {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetContextEntry($self, name, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        data.type = CMPI_null;
        data.state = CMPI_notFound;
        data.value.chars = NULL;
    }
    return data;
  }

  /*
   * Get entry by index or name
   * call-seq:
   *   get_entry_at(index) -> [name, CMPIData]
   *   [index] -> [name, CMPIData]
   *
   * returns a name:string,value:CMPIData pair
   */
#if defined (SWIGRUBY)
  %alias get_entry_at "[]";
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV* 
#endif
  __type get_entry_at(
#if defined (SWIGRUBY)
  VALUE pos
#else
  int index
#endif
  )
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data;
    const char *name;
#if defined (SWIGRUBY)
    if (FIXNUM_P(pos)) {
      data = CMGetContextEntryAt($self, FIX2LONG(pos), &s, &st);      
    }
    else {
      name = target_charptr(pos);
      data = CMGetContextEntry($self, name, &st);
    }
#else
    data = CMGetContextEntryAt($self, index, &s, &st);
#endif

    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
    if (s)
      name = CMGetCharPtr(s);
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, PyString_FromString(name));
    PyTuple_SetItem(result, 1, tdata);
#else
    result = Target_SizedArray(2);
    Target_Append(result, Target_String(name));
    Target_Append(result, tdata);
#endif
    TARGET_THREAD_END_BLOCK;
    if (s)
      CMRelease(s);
    return result;
  }

  /*
   * Get number of entries in Context
   */
  CMPICount get_entry_count(void) {
     return CMGetContextEntryCount($self, NULL); 
    // TODO CMPIStatus exception handling
  }

}
get_entry_count(p1) click to toggle source

Get number of entries in Context

CMPICount get_entry_count(void) {
     return CMGetContextEntryCount($self, NULL); 
    // TODO CMPIStatus exception handling
  }

}