|
Yes, I had wondered myself if it is any method to see where is the error in this macro functions because compiler says generally that is an error in a macro function but you have to search through all lines of the code to see where the error could be.
And those backslash are very wierd, I don't know what is their role.
|
|
|
|
|
The backslashes are there to tell the macro processor to include them all until it finds a line that just ends in a newline.
#define FOO(x) \ // means the definition continues onto the next line
x *= 25; \ printf("X = %d\n");
|
|
|
|
|
I would like to go over some old code and replace the use of CString (MFC / ATL) with a multiplatform, C++ 20 equivalent. Can I use std::format and if so, then how?
|
|
|
|
|
std::format is not directly compatible with sprintf formatting codes. From what I've seen there are different ways to go about this:
- do sprintf to a temporary buffer and assign buffer to a std::string
- switch to string streams (std::stringstream) and their "<<" operator
- switch to std::format and their "{}" style formatting.
None is automatic and about equally unpleasant.
Mircea
|
|
|
|
|
WARNING Way off, in the left field, the coding subject - relax , I am NOT posting any coding questions...
The attached code , which I could not post to show "visualize white space " setting contains
plenty of white space.
The editor has an option to "remove white space" , but only in actual line of code .
which "auto indent" happily recreate...
The "remove white space" DOES NOT remove empty lines...
I am asking - is this normal in any decent editor NOT to have an option to remove "white space" in between lines of code? Or does such option exists and I have no idea what it would be called.
{
qDebug()<< "Current raw text " << resultClean;
str= SubRegularExpressionExt("((\\w+)$)", resultClean,2 ); //TOK line
qDebug()<< "Current extracted text ((\\w+)$)" << str;
str= SubRegularExpressionExt("(\\w+)*", resultClean,2 ); //TOK line
qDebug()<< "Current extracted text (\\w+)*" << str;
str= SubRegularExpressionExt("(\\w+)", resultClean,2 ); //TOK line
qDebug()<< "Current extracted text (\\w+)" << str;
//"((\\w+)\\s*)*",
str= SubRegularExpressionExt("((\\w+)\\s*)*", resultClean,2 ); //TOK line
qDebug()<< "Current extracted text ((\\w+)\\s*)*" << str;
}
|
|
|
|
|
Yes, the option to remove blank lines doesn't usually exist.
|
|
|
|
|
Answering questions is also a skill , especially without unasked / uncalled for preaching and other innuendos and insults.
Have a swell day and do not quit your day job.
|
|
|
|
|
I all I did was answer your question. What the did i do wrong?
Quote: I am asking - is this normal in any decent editor NOT to have an option to remove "white space" in between lines of code?
|
|
|
|
|
14968771 often answers like that. Similarly gives instructions in his questions as to how you must answer.
|
|
|
|
|
Wow.
The quality of the question directly dictates the quality of the answer.
|
|
|
|
|
IIRC a few years ago he actually complained about this in Bugs 'n' Sugs. 
|
|
|
|
|
|
Yeah, "working as expected".
|
|
|
|
|
First:Member 14968771 wrote: I am asking - is this normal in any decent editor NOT to have an option to remove "white space" in between lines of code? being answered withYes, the option to remove blank lines doesn't usually exist. is a direct, clear answer to your question, and certainly doesn't justify your reaction:Answering questions is also a skill , especially without unasked / uncalled for preaching and other innuendos and insults. I have no idea why you show this kind of reaction to a simple (and correct) answer to exactly what your were asking for.
Then: To remove blank lines in Notepad++, I first delete all trailing spaces at end of lines (NP++ has a command for that). Then I replace two consecutive newlines with one newline. NP++ can handle both ISO standard, Mac and *nix newlines, and you have to specify the correct format for the search to match, and you have to select 'Search mode: Extended'.
I guess that any editor that can match on newlines of various kinds can be used in a similar way to remove blank lines.
|
|
|
|
|
My guess is that Member 14968771 does not realise that what's below the horizontal line is simply Dave's signature. He's reading it as a personalised response to his question, misconstruing it entirely and taking it as a personal dig.
|
|
|
|
|
He gives offence freely, and takes it at the drop of a hat.
|
|
|
|
|
Please understand that I am asking here and it is NOT a Qt question.
My task is to start a new process - the parameters are "application" and its parameters.
The basic process builds a "Database" and I am not so sure about "bin/sh" - I guess it "runs" a shell...
It works and there is no need to get into why at this point.
The "problem" is - the "process" is running and I need to interact with it.
I can use "write" but I have no idea when and where and how.
In the enclosed snippet the "info\n" is "send" to the file ( shell?) before it is finished...
I do understand that Qt process can "wait for finished " and I can also get a SIGNAL when the file is actually done building. What I do not get - if the process is actually /physically building / writing a file - what does "wait for finished " waiting for ?
Again - I am not asking how to code Qt , I am asking how to code so I can "write" the additional stuff in right time.
std::string Database = BT_DATABASE_TEST;
std::string Command = "bluetoothctl ";
std::string command = Command + std::string(" | tee ") + Database + std::string(" | tee /tmp/temp");
QP->start("/bin/sh", QStringList() << "-c" << command.c_str());
qDebug()<< "TEST QProcess CONTINUE DEBUG point @line " << QString::number(__LINE__);
QP->waitForFinished();
QP->write("info\n"); writes too soon
qDebug() << QP->readAllStandardError();
qDebug() << QP->readAllStandardOutput();
|
|
|
|
|
I am assuming that your QP pointer is a reference to an object of QProcess Class | Qt Core 6.3.2[^]. As stated in the documentation the start method assumes the device mode as ReadWrite , which if it follows the normal rules, suggests you can write to and read from the started process. But writing will only work if the started process is waiting for input on its stdin stream. As far as I can see your started process is a simple shell pipeline to write some data to stdout and a couple of files. So it is not likely to be waiting for input from an external source.
|
|
|
|
|
After more research - I have two distinct usage of the "command" (QProcess) - one writes to the file and terminates and the other one is "interactive" - writes to the file and expects input.
As of now I can "monitor" the first one two ways - in code - wait for finished or using "finished" SIGNAL. Right now my SIGNAL is "readyWrite" which ( the name ) does not make much sense - BUT it works with non - interactive command. I am going to take a closer look at QProcess SIGNALs - at least make more sense with non interactive command.As of now I just start the QProcess , and I am not directly ( using SIGNALs) verifying it is actually running / started.
After I clean that up I'll take a look at interactive part. Not sure where to start.
|
|
|
|
|
Member 14968771 wrote: Not sure where to start. The logical place is a tutorial on QProcess. You can only communicate with an independent process in this way, when the input and output streams are connected. The default option to the start method sets QIODeviceBase::OpenMode mode = ReadWrite . Does that mean that you can write to the process or not? Only a QT expert can advise on the answer.
|
|
|
|
|
I have verified that I can "write" to QProcess - the question remains when.
Until now the command I have been testing with - which is why I am reluctant to post in QT forum - has been one of the challenges. There is no definite pattern when the command is "single shot" or interactive - depends on how it has been used before.
|
|
|
|
|
|
I am making progress - one of the issues was I was getting multiple "readyRead" SIGNAls.
Not sure why... Now I am getting only one per "start(...) " QProcess and my process stays open.
|
|
|
|
|
1. Why putting #define in char "string" won't process the "command" to "start a new process" , however,
compiler is not giving an error ?
In debug mode I have literal BT_DATABASE_TEST in "command",
2. I need to make the primary text (*.txt) file a variable - how ?
#define BT_DATABASE_TEST "../../BT_DATABASE/BluetoothDatabase.txt"
const char *command = "bluetoothctl show | tee ../../BT_DATABASE/BluetoothDatabase.txt | tee /tmp/temp";
QP->start("/bin/sh", QStringList() << "-c" << command);
|
|
|
|
|
1. You can concatenate strings. Like this:
#define BT_DATABASE_TEST "../../BT_DATABASE/BluetoothDatabase.txt"
const char *command = "bluetoothctl show | tee " BT_DATABASE_TEXT " | tee /tmp/temp";
2. Maybe something like this:
std::string var = "blah_blah.txt";
std::string command = std::string("bluetoothctl show | tee ") + var + std::string("" | tee /tmp/temp");
QP->start("/bin/sh", QStringList() << "-c" << command.c_str());
Mircea
|
|
|
|