qstring .arg like thing in pure c++
-
@user4592357 said in qstring .arg like thing in pure c++:
as the title suggests, i need a way to format std::string like QString does with .arg(), but i only wanna use c++.
i know that there's boost class to do that (namely, boost::format) but i don't to attach 3rd party since if i do, the project will become heavy (boost is like 1.2gb)
Boost has a tool to extract only needed parts
-
thanks, but seems like all the folder got copied
here's how i did it:
bcp.exe --boost=..\..\ format C:\Documents\proj\dependencies\boost_1_65_1\boost
-
@user4592357 said in qstring .arg like thing in pure c++:
or i'm doing something worng?
Exactly, you are doing the difficult way. Do not copy every file in your folder.
- just add 1 line in the project file (assuming you use qmake on windows):
INCLUDEPATH += C:/Boost/boost_1_65_0
- re-run qmake
- add
#include<boost/format.hpp>
in your source file
- just add 1 line in the project file (assuming you use qmake on windows):
-
@user4592357 The above has nothing to do with Qt, just with the build system you use.
Since you posted here I supposed you were using Qt Creator.
If you use visual studio you should just addC:\Boost\boost_1_65_0
to the "Additional include directories" under Project Properies->C/C++->General -
i've done that with the whole 1.2gb boost directly. that works
now i need to send the project to my teacher but i don't want to include 1.2gb of files.
and how can including just the header work if it includes other files? i still don't get it
-
visual studio 2017 on windows 10
-
@VRonin said in qstring .arg like thing in pure c++:
if you use visual studio you should just add C:\Boost\boost_1_65_0 to the "Additional include directories" under Project Properies->C/C++->General
Did you try this before copying the 1.2 GB? of course
C:\Boost\boost_1_65_0
is just an example and you should point to the folder where you have downloaded boost -
What about stringstream?
(http://en.cppreference.com/w/cpp/io/basic_ostringstream)I always use something like this
#include <iostream> #include <sstream> #include <string> std::ostringstream mystring; std::string someText = "something"; int number = 11; mystring << "This is " << someText << " in pure c++ " << number; std::cout << mystring.str();
-
@Konstantin-Tokarev
yes u are right even though for my use cases the list of manipulators
(http://en.cppreference.com/w/cpp/io/manip) is sufficient and keep in
mind that only the brave ones are rewarded :-)