problem with getting index as string

Jochen Katz katz____agentpp.com
Wed May 16 23:13:36 CEST 2001


Hi,

> OctetStr indexStr = my_row->get_index().as_string();
> std::string componentName = indexStr.get_printable();
> 
> Is this the right way to get the index (the index is defined in my private
> mib as DisplayString)?
> 
> There are two rows created in this table with indices "scheduler" and
> "nbcarchive".
> 
> The 1st problem is that there is always a end of line character prefixed to
> the names. So have to take it out.

the end of line character is the length of the string, as the length is
part of the index. You can cut it off before or after calling
as_string().

> The second problem is the indexStr.get_printable() returns the right string
> when it is "nbcarchive" but does not when it is "scheduler". It not only
> prefixes an extra line but also adds hex characters. Looking at
> get_printable() code in octet.cpp, seems to me that it calls
> get_printable_hex() if one of the characters is a printable one (apart from
> other conditions). Seems like the hex method is called for the index
> "scheduler". Why is it so for this index and not for the other index?

The first byte of the scheduler index is 0x09 which will lead to the
call to get_printable_hex(). 

> How do I correctly get the index without this padding or the extra line
> character prefixed? What am I doing wrong?

Just remove the first byte of the index if the length is included in the
index.

Best regards,
  Jochen



More information about the AGENTPP mailing list