VistaIOEncodeAttrValue(3)

πŸ’– VistaIOEncodeAttrValue(3) πŸ’–

okay bestie, gather round, because we're about to talk about VistaIOEncodeAttrValue β€” the little library function that turns your values into cute lil strings. it lives in the Library Functions Manual, and it's giving glow-up for your data ✨


🌸 NAME 🌸

VistaIOEncodeAttrValue β€” literally just: encode an attribute value. that's the whole job. she's an icon, she's a legend, and she's the moment πŸ’…


✨ SYNOPSIS ✨

VistaIOStringConst VistaIOEncodeAttrValue (dict, repn, value)
       VistaIODictEntry *dict;
       VistaIORepnKind repn;
       type value;

and the way type works? it depends on repn, bestie. type is one of VistaIOBit, VistaIOUByte, VistaIOSByte, VistaIOShort, VistaIOLong, VistaIOFloat, VistaIODouble, VistaIOBoolean, or VistaIOString. pick your fighter πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dict β€” may specify a dictionary to be used in translating the value supplied to a keyword that should be returned as the encoded value, or it may be NULL. so like, optional bestie energy. she can come to the party or not, no pressure 🫢
  • repn β€” specifies the representation of the value to be encoded. this is the what kind of thing are we even dealing with parameter.
  • value β€” specifies the value to be encoded. the actual star of the show, the main character πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

VistaIOEncodeAttrValue takes a value and an optional dictionary, and encodes the value as a character string suitable for storage in an attribute list or output to a data file. yes, it's literally the make it string so we can save it function. obsessed 😭

with the dict argument you can provide a dictionary for mapping value to a keyword that will be returned as the encoded value (see VistaIOdictionary(3)). no cap, here's an example: if you pass a value of 1 and a dictionary that associates the value 1 with the keyword ubyte (as the dictionary VistaIORepnDict does), then the string ubyte will be returned. πŸŽ€

and here's the tea β€” dictionaries may be used to map both numeric values and strings to keywords. equal opportunity mapping, we love to see it πŸ’–

but wait. if you supply a dictionary but value is not mentioned in that dictionary, then value itself will be encoded as a string and returned. so nobody gets left out, bestie. the value just shows up as herself. iconic behavior honestly ✨


πŸ”₯ RETURN VALUES πŸ”₯

if successful, VistaIOEncodeAttrValue returns a string that is valid until the next VistaIOEncodeAttrValue, VistaIOSetAttr, or VistaIOSetAttrValue call.

⚠️ okay this is IMPORTANT β€” that returned string is not yours forever. it's valid until the next one of those three calls happens. so if you're holding onto it and then you call one of those, your string is lowkey gone. don't be caught lacking πŸ™ˆ

if, on the other hand, it fails because repn is not one of the representations supported, it returns NULL. that's the sad path. πŸ’€


🌈 SEE ALSO 🌈

(that trailing comma in the original is canon, we don't edit the queen πŸ’…)


πŸ‘‘ DIAGNOSTICS πŸ‘‘

  • Can't encode from repn.'' `` β€” the repn argument is not one of VistaIOBitRepn, VistaIOUByteRepn, ..., VistaIOBooleanRepn, or VistaIOStringRepn.

like, if you hand her a repn she doesn't recognize, she's gonna say exactly that and dip. know the list, bestie 🧚


🌟 AUTHOR 🌟

  • Art Pope <pope@cs.ubc.ca>
  • Adaption to vistaio: Gert Wollny <gw.fossdev@gmail.com>

shoutout to the devs, fr fr 🫢


and that's the whole page, bestie!! VistaIO Version 1.2.14, dated 24 April 1993 β€” yes she's an elder but she still slays, and this manual page is a certified classic. go forth and encode responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ‘‘πŸŒˆβ­