Codesynthesis - Compare string value with sequence in C++
up vote
0
down vote
favorite
I'm new to Codesynthesis and i'm wondering about how i can compare string values with a sequence.
For example i have a Message id "0x100" and i want to check if its in the Send sequences. If its there, i just want to get the Signal name of the Message with the id "0x100" (in this case: "one") and not the whole sequence.
With my code i can get all the Message ids in all Send sequences, but i dont know how to use them to compare it to a string variable respectively just get one element out of the sequence and save it to a string variable.
How can i accomplish this?
Thanks for your help!
This is the xml:
<record>
<signals>
<Send name="Port1">
<Message id="0x100">
<Signal name="one"/>
</Message>
<Message id="0x101">
<Signal name="two"/>
<Signal name="three"/>
<Signal name="four"/>
</Message>
<Message id="0x102">
<Signal name="five"/>
</Message>
<Message id="0x103">
<Signal name="six"/>
</Message>
<Message id="0x104">
<Signal name="seven"/>
<Signal name="eight"/>
<Signal name="nine"/>
<Signal name="ten"/>
</Message>
<Message id="0x105">
<Signal name="eleven"/>
</Message>
</Send>
<Send name="Port2">
<Message id="0x106">
<Signal name="twelve"/>
</Message>
<Message id="0x107">
<Signal name="thirteen"/>
</Message>
<Message id="0x108">
<Signal name="fourteen"/>
</Message>
<Message id="0x109">
<Signal name="fifteen"/>
</Message>
<Message id="0x110">
<Signal name="sixteen"/>
</Message>
</Send>
</signals>
</record>
This is how i read the sequences from the xml:
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
}
}
c++ compare sequence codesynthesis
add a comment |
up vote
0
down vote
favorite
I'm new to Codesynthesis and i'm wondering about how i can compare string values with a sequence.
For example i have a Message id "0x100" and i want to check if its in the Send sequences. If its there, i just want to get the Signal name of the Message with the id "0x100" (in this case: "one") and not the whole sequence.
With my code i can get all the Message ids in all Send sequences, but i dont know how to use them to compare it to a string variable respectively just get one element out of the sequence and save it to a string variable.
How can i accomplish this?
Thanks for your help!
This is the xml:
<record>
<signals>
<Send name="Port1">
<Message id="0x100">
<Signal name="one"/>
</Message>
<Message id="0x101">
<Signal name="two"/>
<Signal name="three"/>
<Signal name="four"/>
</Message>
<Message id="0x102">
<Signal name="five"/>
</Message>
<Message id="0x103">
<Signal name="six"/>
</Message>
<Message id="0x104">
<Signal name="seven"/>
<Signal name="eight"/>
<Signal name="nine"/>
<Signal name="ten"/>
</Message>
<Message id="0x105">
<Signal name="eleven"/>
</Message>
</Send>
<Send name="Port2">
<Message id="0x106">
<Signal name="twelve"/>
</Message>
<Message id="0x107">
<Signal name="thirteen"/>
</Message>
<Message id="0x108">
<Signal name="fourteen"/>
</Message>
<Message id="0x109">
<Signal name="fifteen"/>
</Message>
<Message id="0x110">
<Signal name="sixteen"/>
</Message>
</Send>
</signals>
</record>
This is how i read the sequences from the xml:
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
}
}
c++ compare sequence codesynthesis
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm new to Codesynthesis and i'm wondering about how i can compare string values with a sequence.
For example i have a Message id "0x100" and i want to check if its in the Send sequences. If its there, i just want to get the Signal name of the Message with the id "0x100" (in this case: "one") and not the whole sequence.
With my code i can get all the Message ids in all Send sequences, but i dont know how to use them to compare it to a string variable respectively just get one element out of the sequence and save it to a string variable.
How can i accomplish this?
Thanks for your help!
This is the xml:
<record>
<signals>
<Send name="Port1">
<Message id="0x100">
<Signal name="one"/>
</Message>
<Message id="0x101">
<Signal name="two"/>
<Signal name="three"/>
<Signal name="four"/>
</Message>
<Message id="0x102">
<Signal name="five"/>
</Message>
<Message id="0x103">
<Signal name="six"/>
</Message>
<Message id="0x104">
<Signal name="seven"/>
<Signal name="eight"/>
<Signal name="nine"/>
<Signal name="ten"/>
</Message>
<Message id="0x105">
<Signal name="eleven"/>
</Message>
</Send>
<Send name="Port2">
<Message id="0x106">
<Signal name="twelve"/>
</Message>
<Message id="0x107">
<Signal name="thirteen"/>
</Message>
<Message id="0x108">
<Signal name="fourteen"/>
</Message>
<Message id="0x109">
<Signal name="fifteen"/>
</Message>
<Message id="0x110">
<Signal name="sixteen"/>
</Message>
</Send>
</signals>
</record>
This is how i read the sequences from the xml:
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
}
}
c++ compare sequence codesynthesis
I'm new to Codesynthesis and i'm wondering about how i can compare string values with a sequence.
For example i have a Message id "0x100" and i want to check if its in the Send sequences. If its there, i just want to get the Signal name of the Message with the id "0x100" (in this case: "one") and not the whole sequence.
With my code i can get all the Message ids in all Send sequences, but i dont know how to use them to compare it to a string variable respectively just get one element out of the sequence and save it to a string variable.
How can i accomplish this?
Thanks for your help!
This is the xml:
<record>
<signals>
<Send name="Port1">
<Message id="0x100">
<Signal name="one"/>
</Message>
<Message id="0x101">
<Signal name="two"/>
<Signal name="three"/>
<Signal name="four"/>
</Message>
<Message id="0x102">
<Signal name="five"/>
</Message>
<Message id="0x103">
<Signal name="six"/>
</Message>
<Message id="0x104">
<Signal name="seven"/>
<Signal name="eight"/>
<Signal name="nine"/>
<Signal name="ten"/>
</Message>
<Message id="0x105">
<Signal name="eleven"/>
</Message>
</Send>
<Send name="Port2">
<Message id="0x106">
<Signal name="twelve"/>
</Message>
<Message id="0x107">
<Signal name="thirteen"/>
</Message>
<Message id="0x108">
<Signal name="fourteen"/>
</Message>
<Message id="0x109">
<Signal name="fifteen"/>
</Message>
<Message id="0x110">
<Signal name="sixteen"/>
</Message>
</Send>
</signals>
</record>
This is how i read the sequences from the xml:
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
}
}
c++ compare sequence codesynthesis
c++ compare sequence codesynthesis
edited Nov 22 at 16:09
asked Nov 22 at 15:36
T.Low
13
13
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
FYI: I found the solution. It was quite easy.
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
//Check if theres a message
if (u.id().present()) {
//Put the message in a struct array (same with signals)
info[NumberOfSends].messages[NumberOfMessages] = u.id().get(); //this is how you get it as a string
NumberOfMessages++;
}
}
}NumberOfSends++;
Now you can use this array to compare it to a string.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
FYI: I found the solution. It was quite easy.
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
//Check if theres a message
if (u.id().present()) {
//Put the message in a struct array (same with signals)
info[NumberOfSends].messages[NumberOfMessages] = u.id().get(); //this is how you get it as a string
NumberOfMessages++;
}
}
}NumberOfSends++;
Now you can use this array to compare it to a string.
add a comment |
up vote
0
down vote
accepted
FYI: I found the solution. It was quite easy.
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
//Check if theres a message
if (u.id().present()) {
//Put the message in a struct array (same with signals)
info[NumberOfSends].messages[NumberOfMessages] = u.id().get(); //this is how you get it as a string
NumberOfMessages++;
}
}
}NumberOfSends++;
Now you can use this array to compare it to a string.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
FYI: I found the solution. It was quite easy.
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
//Check if theres a message
if (u.id().present()) {
//Put the message in a struct array (same with signals)
info[NumberOfSends].messages[NumberOfMessages] = u.id().get(); //this is how you get it as a string
NumberOfMessages++;
}
}
}NumberOfSends++;
Now you can use this array to compare it to a string.
FYI: I found the solution. It was quite easy.
string filename = "test.xml";
unique_ptr<record> h(record(filename));
signals::Send_sequence& s(h->signals().Send());
for (signals::Send_iterator i(s.begin()); i != s.end(); ++i)
{
Send::Message_sequence& s2(i->Message());
for (Send::Message_iterator j(s2.begin()); j != s2.end(); ++j)
{
Message& u(*j);
cout << u.id() << endl;
//Check if theres a message
if (u.id().present()) {
//Put the message in a struct array (same with signals)
info[NumberOfSends].messages[NumberOfMessages] = u.id().get(); //this is how you get it as a string
NumberOfMessages++;
}
}
}NumberOfSends++;
Now you can use this array to compare it to a string.
answered Dec 4 at 13:35
T.Low
13
13
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434249%2fcodesynthesis-compare-string-value-with-sequence-in-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown