class Cmpi::CMPIArgs

CMPI Arguments

Arguments are passed in an ordered Hash-like fashion (name/value pairs) and can be accessed by name or by index

CMPIArgs

Public Instance Methods

arg_count() click to toggle source

Gets the number of arguments contained in this Args.

int arg_count() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    int result;

    result = CMGetArgCount($self, &st);
    RAISE_IF(st);

    return result;
  }
}
each() { |get_arg_at(i)| ... } click to toggle source
# File cmpi.rb, line 546
def each
  0.upto(size-1) do |i|
    yield get_arg_at(i)
  end
end
get(p1) click to toggle source

Gets a named argument value.

CMPIData get(const char *name) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData result;

    result = CMGetArg($self, name, &st);
    RAISE_IF(st);

    return result;
  }

#if defined (SWIGRUBY)
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV * 
#endif
  /*
   * Get an Argument value by index.
   * Returns a pair of value and name
   *
   * call-seq:
   *   get_arg_at(1) -> [ "name", value ]
   * ** Python returns value, name pair !
   *
   */
  __type get_arg_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetArgAt($self, index, &s, &st);

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


  %alias arg_count "size";

  /*
   * Gets the number of arguments contained in this Args.
   *
   */
  int arg_count() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    int result;

    result = CMGetArgCount($self, &st);
    RAISE_IF(st);

    return result;
  }
}
get_arg_at(1) → [ "name", value ] click to toggle source
** Python returns value, name pair !

Get an Argument value by index. Returns a pair of value and name

__type get_arg_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetArgAt($self, index, &s, &st);

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


  %alias arg_count "size";

  /*
   * Gets the number of arguments contained in this Args.
   *
   */
  int arg_count() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    int result;

    result = CMGetArgCount($self, &st);
    RAISE_IF(st);

    return result;
  }
}
set("arg_name", arg_value, arg_type) click to toggle source

Adds/replaces a named argument.

void set(char *name, const CMPIValue * value, const CMPIType type) 
  {
    RAISE_IF(CMAddArg($self, name, value, type));
  }


  %alias get "[]";

  /*
   * Gets a named argument value.
   *
   */
  CMPIData get(const char *name) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData result;

    result = CMGetArg($self, name, &st);
    RAISE_IF(st);

    return result;
  }

#if defined (SWIGRUBY)
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV * 
#endif
  /*
   * Get an Argument value by index.
   * Returns a pair of value and name
   *
   * call-seq:
   *   get_arg_at(1) -> [ "name", value ]
   * ** Python returns value, name pair !
   *
   */
  __type get_arg_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetArgAt($self, index, &s, &st);

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


  %alias arg_count "size";

  /*
   * Gets the number of arguments contained in this Args.
   *
   */
  int arg_count() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    int result;

    result = CMGetArgCount($self, &st);
    RAISE_IF(st);

    return result;
  }
}
to_hash() click to toggle source
# File cmpi.rb, line 551
def to_hash
  h = {}
  each do |name,val|
    h[name] = val
  end
  h
end
to_s() click to toggle source
# File cmpi.rb, line 558
def to_s
  s = ""
  each do |name,val|
    s << ", " unless s.empty?
    s << "#{name.inspect} => #{val}"
  end
  "{ #{s} }"
end