|
Would it be too lengthy or tedious an explanation to explain the need to modify the iterator. I find such a need quite unusual and do not recall ever having to perform same.
|
|
|
|
|
No problem: the iterator is a pointer in a UTF-8 encoded string and the function (called next ) has to advance to the next code point (1, 2, 3 or 4 char ). If iterator is at end of string it doesn't advance.
Although a very simple function, I had a number of design decisions to make:
- How should I deal with improperly encoded UTF-8 strings? I decided to return false if the string is not properly encoded.
- Should I just leave out the boundary check and just document it? I decided against as it would have been unsafe.
And the last one I was asking about: For limit check, should I just pass the string or the end iterator.
Mircea
|
|
|
|
|
I am NOT a C++ guy, so bear with me.
I am working on a C#/WPF app that references two C++ projects.
We just converted the solution from .Net Framework to .Net Core 6.0, and now the C++ projects won't compile while in the solution. If I open the C++ projects stand-alone, they compile file.
Primarily I'm getting the compile time error
'System': a namespace with this name does not exist
I've been Googling and 99% of the answers all say this. I've tried the answers and still get the same errors.
At this point I need help. I'm guessing it's some kind of configuration issue, but I really don't know.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Richard MacCutchan wrote: What is the context
Not sure what you mean by "what is the context". Like I said, the project is in a solution with a C#/WPF project and the C++ project now doesn't compile.
Richard MacCutchan wrote: and are you sure this would not fit better in Managed C++/CLI Discussion Boards
I have no clue. But I could move it there.
Again, I have ZERO C++ experience, so I'm really in the dark with all this.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: Not sure what you mean by "what is the context" All you have given us is an error message. We have no idea whether this is unmanaged or managed code, what the actual code that causes the error looks like &c.
|
|
|
|
|
OK, so here's the lines of code that are failing:
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
This error occurs in the using statements in every C++ file in the project.
It's a .Net 6 project, so I'm assuming it Managed code.
I'm not trying to be difficult, but I just don't know what I'm looking at so it's hard for me to know what to post here.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
OK thanks. I'll take a look
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hi
I have the following
struct tcbholder
{
char* tcb;
char programname[8];
struct stdecs stdecsx;
list <stdecs> strptr;
list <stdecs>::iterator stfirstptr;
list <stdecs>::iterator straverse;
};
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc ablkdescx;
struct blkdesc fblkdescx;
list <blkdesc> ablkptr;
list<blkdesc>::iterator blktraverse;
list<blkdesc> fblkptr;
}
struct blkdesc
{
char type;
int blkaddr;
int blklen;
};
I declare a list class
list<tcbholder> tcbcollecter;
then a iterator
list <tcbholder>::iterator tcbitrate;
I am able to initialize the main iterator
tcbitrate = tcbcollecter.begin();
However when I try
tcbitrate->straverse = tcbitrate->strptr.begin();
I get the following
_STL_VERIFY(this->_Ptr != _Mycont->_Myhead, "cannot dereference end list iterator");
its in the list member line 151
Dont Understand
Thanks
|
|
|
|
|
It means that your "tcbcollecter" list was empty when you assigned the "tcbitrate" iterator. Calling begin() on an empty list will give you the end() iterator, because there is no real element to point to. You can't dereference it because it doesn't point at anything.
|
|
|
|
|
How would I solve this problem would calling tcbitrate->push_back solve it after that there is something on the list though the members of tcbcollector have not been assigned values
|
|
|
|
|
Instead of trying to manipulate the contents of these structs from outside I would add member functions to do it.
|
|
|
|
|
Was thinking how to that don’t know if it’s practical my list represents the output of VSMLIST z/os assembler mainframe macro representing the amount allocate free and I unallocated storage for an address space
It’s listed by storage blocks ( address and length ) storage descriptors representing a storage subpool which different attributes and storage keys and the TCB task control blocks of the task that own them
|
|
|
|
|
Quote: tcbitrate = tcbcollecter.begin();
Quote: tcbitrate->straverse = tcbitrate->strptr.begin(); If tcbcollecter is empty then the complaint is correct.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
I think I finally got it a iterator is for traversing
I first have to populate the list
I’m in bed now with my iPhone I’ll try this again after work
Thanks
|
|
|
|
|
Forgive me to be so bold - but I just cannot believe that in versatile forum like
this there is nobody who can at lest give me some idea how to resolve this.
It seems to be a problem that everybody wants SINGLE system problem
- that seldom works in real life.
As the title suggest - I need to connect Qt generated object / window to Linux "terminal"
(operating system ) native window.
I can highlight ( Using Qt) the text in the native window (!)
but Qt gives me no indication it did that.
PLEASE - NO PASSING THE BUCK TO QT FORUM - THEY HAVE NO IDEA HOW TO PROCEED - IT IS NOT Qt ISSUE IN THEIR ASSESSMENT -HENCE out OF THEIR narrow minded LEAGUE.
ps i WILL REMOVE THIS , AND MY SIMILAR POSTS, IF i DO NOT GET REASONABLE REPLY , JUST TO SAVE SPACE HERE.
Edited / addendum
I am still looking for somebody who is willing to help me instead of just posting text.
If it bothers you that my post is not specifically C/C++ code , please ignore it .
If it bothers you that my post is too complex , please ignore it also.
If it bothers you that my post is poorly written - read how to post / answer questions.
Is short - write something helpful and constructive.
I am asking for real help to SOLVE this.
The main issue is - QProcess runs external "terminal" application - I have tried several with same results - such external application builds / create "window" , which is by C code attached to object created by QtCreator. Window created by Qt displays data retrieved from the external app ( terminal) , I am interested in text only so far.
Such data ( text ) can be highlighted by using mouse - as any QT created text,
However, this highlighted text is NOT DETECTED by QT - because of what ?
And that is the main (IMHO) question which is so far not answered...
How does terminal created window "connect" to Qt ? - that is the question.
Original post
This simple command , entered in Linux "terminal" application results in expected output from "Bluetoothctl" .
qterminal -e bluetoothctl
When this command is implemented in C++ code , an new "native window" is displayed above current application windows.
Similar code can be implemented in C++ for "xterm" or other terminal emulation.
My question is - how do I acccess this "native window " in my C++ application ?
I can move the "native window" into desired position using winId() but cannot access any data displayed in the native window.
Thanks for reply. I am actually looking for "discussion forum" . I am running out of ideas how to fix my problem.
Yes , I did try qterminal - it has no option to run command with options - so I ended up with xterm.
It works OK, but I cannot figure out how to FULLY integrate it with my application.
I am able to display the command output in my app "window" but it is NOT really my app window - some folks call it "xterm native window ".
So I can display it - it is "inside my other window" , I can move it , using my app "wrapper window", but I cannot process anything in it.
I am actually hoping that somebody with good grasp of "windows hierarchy" can shed some light on this.
In not so techie terms - how do I process data in xterm native window ?
I will take a look at xterm man again, maybe the answer is there.
|
|
|
|
|
 Quote: Forgive me to be so bold - but I just cannot believe that in versatile forum like
this there is nobody who can at lest give me some idea how to resolve this.
It seems to be a problem that everybody wants SINGLE system problem
- that seldom works in real life.
As the title suggest - I need to connect Qt generated object / window to Linux "terminal"
(operating system ) native window.
I can highlight ( Using Qt) the text in the native window (!)
but Qt gives me no indication it did that.
PLEASE - NO PASSING THE BUCK TO QT FORUM - THEY HAVE NO IDEA HOW TO PROCEED - IT IS NOT Qt ISSUE IN THEIR ASSESSMENT -HENCE out OF THEIR narrow minded LEAGUE.
ps i WILL REMOVE THIS , AND MY SIMILAR POSTS, IF i DO NOT GET REASONABLE REPLY , JUST TO SAVE SPACE HERE.
Edited / addendum
I am still looking for somebody who is willing to help me instead of just posting text.
If it bothers you that my post is not specifically C/C++ code , please ignore it .
If it bothers you that my post is too complex , please ignore it also.
If it bothers you that my post is poorly written - read how to post / answer questions.
Is short - write something helpful and constructive.
"Terms and conditions apply to your answer."
You're doing it again, and you wonder why nobody, in any forum, is willing to even talk to you, let alone help you.
|
|
|
|
|
Member 14968771 wrote: How does terminal created window "connect" to Qt ? - that is the question. And as so often suggested, that is a question for a QT forum and has nothing to do with C/C++. Unless you can show some actual code and explain (without all the unnecessary orders) what the problem is, there is very little anyone here can do to help you. So try this template:
---------------------------
In the following code, the instruction at line x throws an out of range exception, even though the calculation appears to be correct. blah blah ...
int value = 5;
do
{
} while (values < 10);
---------------------------
That's all we need, not a load of 'instructions' about how we must answer your questions in a form that you think you deserve. Remember, we are all volunteers here and actually do this because we like to help people. What we do not care for is being given orders, especially by those who somehow think we are their employees.
|
|
|
|
|
Here is work in progress copy of the problematic code.
It does not matter what terminal application is actually coded,
the results are same
with this parameter the terminal window is attached / on top of Qt object window
into" <<QString::number(winId())
without the above parameter
the terminal window became free floating anywhere on desktop and can be moved by mouse
the issue is
how to "link " Qt process created terminal window with Qt running application.
The odd thing is - I can highlight the terminal window text using mouse in Qt running application,
hence Qt is aware of the terminal window , hence the question remains - how to use this involvement , where is the connection between running QT app and running "terminal"?
I was hoping to run other applications FROM Qt and cannot do without solving this first.
My best guess is - since QT QProcess starts / execute EXTERNAL application and allegedly has no
knowledge about the executing application
( how does it highlight the terminal text without such knowledge ?)
the relation may be between Qt and operating system.
Same question posted in Qt forum produced this
not a Qt problem
extract the terminal text using regular expression -
done that and that does not get even close
to answer the relations question
PS If it helps I could post a link to Qt forum where I can post screen shot
to illustrate the problem.
<pre> QProcess *process = new QProcess(parent);
processTERMINAL = new QProcess();
QString exec = "xterm";
QStringList params;
params << "-T" << "bluetoothctl no options (interactive) case 0 +hold " << "-fa" <<"Monospace" << "-fs" << "14"<< "+hold" <<
"-into" <<QString::number(child->winId())<<
"-e" << "bluetoothctl";
qDebug() <<"params " << params;
processTERMINAL->start(exec, params);
if(processTERMINAL->waitForStarted())
{
qDebug() << " processTERMINAL->waitForStarted() OK";
qDebug() << processTERMINAL->readAllStandardError();
qDebug() << processTERMINAL->readAllStandardOutput();
}
|
|
|
|
|
I am sorry, but whatever the people at QT say, this is purely a QT question. Every single line in that code is using a QT command or object so that is where the answer(s) lie.
[edit]
Member 14968771 wrote: how to "link " Qt process created terminal window with Qt running application. Not sure what you mean by that. The started terminal is a separate process, so the only connection between the two is the process id which allows the caller to determine whether the started process is running or not.
[/edit]
|
|
|
|
|
The terminal app is started by Qt. Qt by itself does no keep track of terminal.
My comment on highlighting the terminal window text "inside " Qt app is NOT Qt
doing -
hence if I start the terminal without "into" command option I can still highlight the text in the terminal "floating "window.
I do not know why... or what process is highlighting the terminal window text IF Qt is no longer in the picture.
That is the essence of this - how to keep Qt and external application communication going. Starting an external process / application without being able to communicate with it is useless ( to me ).
It all runs under operating system and there should be a way to accomplish this.
And if the answer is YES ( in runs under OS ) and IT IS NOT C problem I'll give up.
|
|
|
|
|
I suspect that what's going on is that when you highlight some text in your terminal window, its getting copied to a clipboard in the GUI. Or perhaps its not getting copied and you need to tell the terminal app to copy the text - usually, but not guaranteed to be, CTL-C. Otherwise, you might need to look into the GUI API for accessing contents of the clipboard. Note that many XTerm emulators seem to have 2 independent clipboards. There's one that you get when you merely highlight the text, and which you can then usually paste with middle-button on the mouse. There's also the Cut/Paste (CTL-C/CTL-V) clipboard. The two sometimes seem to be synchronized, but not always. In general, I think you should prefer the Cut/Paste method, as that seems to copy text to the GUI's idea of the clipboard, and is usually what you get back when you Paste. This is all a bit hand-wavy, because it seems like there's no hard and fast rules about what gets copied where during a highlight and/or a Copy/Paste.
Keep Calm and Carry On
|
|
|
|
|
I am currently looking into this hack
xterm has "log file " option and I am already redirecting the xterm output to
a temp text file. Unfortunately they both include control characters, but I already have a function to extract only the humanly readable text.
The hack would include adding another GUI level
I currently have a single subwindow , I would add
a new top layer "TAB" object and create
"raw " xterm output tab -same as today "native window"
extracted text tab - QT accessible
plus my usual TRACE tab
Little convoluted but that looks as the best solution so far
Then I can "copy and paste " from one subwindow (tab) to another
as my task initially called for.
|
|
|
|
|
When you highlight text in a terminal it can usually then be copied by some keystrokes or menu option. That is fairly standard throughout Windows, MacOS and Linux. You can then paste it into another running application (e.g. the QT process that launched the terminal), but as far as I am aware you still need to do it manually. If you want direct connection between a calling and called process, then the called process needs to be a console type application. You can then connect the stdout of the called process to stdin of the caller, so the caller can read what the called process writes. The QProcess documentation explains how to do it.
|
|
|
|