c - printf with reference arguments -
imagine having label after created updates x amount of times / sec. text of label given format-specifier text (ala printf), , arguments format-specifier updated on redraw, because arguments format specifier pointers respective values. variant of sprintf work this?
the code work this:
/* client */ createlabel("value %f", &myfloatvalue);
i haven't quite figured out way yet, have ideas? guess 1 parse format text, retrieve pointers (and types), , store them object in list, later reprint text , maybe delegate formatting objects themselves, passing them textbuffer.. hmmm
btw, interface c, host c++.
okay got "working" prototype, it's written in assembler. anyway demonstrates supposed use of api. can see portable way / have better idea implementation? it's pretty large i'm posting on pastebin: http://pastebin.com/h8zpwb4u
so createlabel
interface store format string, along addresses of variables you're wanting display within string. use standard old sprintf
reformat text. careful pointers data, , make sure invalidate them when necessary.
i'm not sure problem is. else looking for? sprintf
capable of doing want, you're going have track format string , variable addresses yourself.
Comments
Post a Comment