poco icon indicating copy to clipboard operation
poco copied to clipboard

[Feature Request] Poco::format does not recognize the `P` type

Open Smurf-IV opened this issue 2 years ago • 2 comments

As per the standard types, P is supposed to dump a pointer address (As hex reference) into the string

https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm

But Poco::format does not (in 1.12.4 anyway !)

Smurf-IV avatar Oct 18 '23 14:10 Smurf-IV

send a pull request with a testcase if you want this in

aleks-f avatar Nov 13 '23 09:11 aleks-f

I think the only way this can possibly work is forcing the user to cast to void*.

Format.cpp

case 'p':
    str < std::hex << std::showbase << AnyCast<void*>(*itVal++);
    break;

Then the calling code would be:

int value = 0;
Poco::format("%p", static_cast<void*>(&value));

I don't believe it's possible to remove the static_cast because of the way Poco::Any works. Even if it were possible, it would require extra machinery inside Poco::Any to work.

andrewauclair avatar Feb 19 '24 17:02 andrewauclair

@andrewauclair typed pointers are accessible, see testAnyPointer(), some accessors/detection has been added for 1.14. But I have no need, time or desire to add this feature and it's just creating noise - people post things then disappear, so I decided to close it

aleks-f avatar Feb 19 '24 19:02 aleks-f

That sounds good to me. I've moved to using fmtlib myself.

andrewauclair avatar Feb 19 '24 22:02 andrewauclair