 |
|
 |
""111" "22,2" "333"","bbbb"
after paring
1.""111" "22
2.2" "333""
3."bbbb"
But it is wrong
i think it must be
1.""111" "22,2" "333""
2."bbbb"
xxxxxxxx
|
|
|
|
 |
|
 |
Had the occasion today to once again come back to this and just wanted
to say thanks.
Roy
|
|
|
|
 |
|
 |
Hello.I want typing phonetic to edit control, how can typing letterlike sysbol to MFC?
|
|
|
|
 |
|
 |
What?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
To build token strings from scratch using AddField, I patched as follows:
void CQStringParser::AddField(CString sText)
{
CString original;
if (GetOriginalString().IsEmpty())
original = sText;
else
original = GetOriginalString() + CString(m_cDelimiter) + sText;
ResetOriginalString(original, m_cDelimiter, m_cQuoter);
}
Useful class, thank you !
|
|
|
|
 |
|
 |
hello ,
i used your class for parsing.
its working well.and now i need to parse a
long japanese text file .That text file
is very big consisting of long japanese
text sentences with or without delimeters.
how can i parse the text file and convert into
meaningful words with proper delimeters.
can u help me to get some idea on this??
Waiting for your reply,
Senthil
|
|
|
|
 |
|
 |
std::string CQStdStringParser::GetField(int nIndex, bool bStripQuotes)
{
std::string sBuffer = "";
if (m_nCount >= nIndex)
{
STRING_ARRAY::iterator iter = m_aStrings.begin();
std::advance(iter, nIndex);
sBuffer = (*iter).c_str();
if ( bStripQuotes && (sBuffer.length() > 1) )
{
if (sBuffer.at(0) == m_cQuoter && sBuffer.at(sBuffer.size()-1) == m_cQuoter)
{
sBuffer.erase(sBuffer.size()-1, 1);
sBuffer.erase(0, 1);
}
}
}
else
{
sBuffer = "ERROR: Array index out of range.";
}
return sBuffer;
}
Edwin Geng
www.chosensoft.com[^]
|
|
|
|
 |
|
 |
Hi,
I try to parse the following string:
name="My Test" value="Test 123 of new" info="blah blah 123 123" version="3 0 0 2"
and the resuts I get are quite strange.
It looks like it does not realy like the =" stuff.
(Parse char is " " (space), Quote Char is "\"" (quote)).
Any idea?
Thanks,
Tutu.
|
|
|
|
 |
|
 |
Make it a comma-delimited string like this:
name="My Test",value="Test 123 of new",info="blah blah 123 123",version="3 0 0 2"
At that point, you don't need the quotes around the data either.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Hi!
I used the CStringParser class and have found some bugs in the STL part.
Here they are (fixes included):
File: QStdStringParser.cpp
void CQStdStringParser::AddField(std::string sText)
{
//m_aStrings.push_back(sText);
//RebuildOriginalString();
// Should be:
std::string original = GetOriginalString() + std::string(1,m_cDelimiter) + sText;
ResetOriginalString(original, m_cDelimiter, m_cQuoter);
}
void CQStdStringParser::SetField(int nIndex, std::string sText)
{
if (nIndex > 0 && nIndex <= m_nCount)
{
STRING_ARRAY::iterator iter = m_aStrings.begin();
std::advance(iter, nIndex);
// Simpler solution
(*iter) = sText;
#if 0
// First insert element before iterator
m_aStrings.insert(iter, 1, sText);
// Now remove unwanted element
m_aStrings.erase(iter);
// Iterator is now no longer valid !
#endif /* 0 */
RebuildOriginalString();
}
else
{
// error
}
}
File: TestStringParserDlg.cpp
void CTestStringParserDlg::OnParse2()
{
CString sText;
m_ctrlOriginal2.GetWindowText(sText);
m_ctrlParseChar2.GetWindowText(m_sParseChar2);
m_ctrlQuoteChar2.GetWindowText(m_sQuoteChar2);
m_sStdOriginal = (const char*)sText;
char cParser = (m_sParseChar2.GetLength() > 0) ? m_sParseChar2[0] : '\0';
char cQuoter = (m_sQuoteChar2.GetLength() > 0) ? m_sQuoteChar2[0] : '\0';
// Old code
//char cParser = (m_sParseChar2.GetLength() > 0) ? m_sParseChar1[0] : '\0';
//char cQuoter = (m_sQuoteChar2.GetLength() > 0) ? m_sQuoteChar1[0] : '\0';
m_pStdParser->ResetOriginalString(m_sStdOriginal, cParser, cQuoter);
FillListBox2();
}
BTW: It's a nice class... and the bugs an only related to the STL part ...
|
|
|
|
 |
|
 |
You found a bug in the example app, but not in the class itself.
L. Kohnert wrote:
</small>void CQStdStringParser::AddField(std::string sText)
{
//m_aStrings.push_back(sText);
//RebuildOriginalString();
// Should be:
std::string original = GetOriginalString() + std::string(1,m_cDelimiter) + sText;
ResetOriginalString(original, m_cDelimiter, m_cQuoter);
}
I don't think so. AddField adds a new element to the list, and then rebuilds the original string from the new list. Yours is just a different (and less efficient) way to do it. I don't see any problems in the existing code.
<small>L. Kohnert wrote:
</small>void CQStdStringParser::SetField(int nIndex, std::string sText)
{
if (nIndex > 0 && nIndex <= m_nCount)
{
STRING_ARRAY::iterator iter = m_aStrings.begin();
std::advance(iter, nIndex);
// Simpler solution
(*iter) = sText;
#if 0
// First insert element before iterator
m_aStrings.insert(iter, 1, sText);
// Now remove unwanted element
m_aStrings.erase(iter);
// Iterator is now no longer valid !
#endif /* 0 */
RebuildOriginalString();
}
else
{
// error
}
}
Again, not a "bug", just a different way to do it.
For the record, I see no real benefit in using STL. I write Windows apps using VC++, and have no desire, inclination, requirement, nor interest in porting them to another platform. I provided the STL version for those people who absolutely refuse to use MFC. I learned exactly enough about STL to convert the class to use the [STL] library. However, I thank you for pointing out an eaiser way to replace a given list element with new data.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
 |
|
 |
I can't understand why it's rated so low. I've used it several times in production code and it's saved hours of work and worked flawlessly.
Maybe it's the real world nature of it. Lot's of articles that are useful in the real world or in business applications primarily seem to get low ratings for some reason.
Who knows?
Anyway, it's great and a real time saver, thank you.
|
|
|
|
 |
|
 |
Thanks. I think the rating is okay. It's certainly not ground-breaking, but it certainly is, as you said, a time-saver
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
 |
|
 |
Would be even better if you could use a delimiter of more than one character in length (eg. "XXXX").
You can't ask for everything though!
MT
http://www.teddev.com
|
|
|
|
 |
|
 |
I have *never* run into an instance where I had to parse a string using a delimiter string.
Can you give me a real-world instance where it would be truly useful?
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
|
|
|
|
 |
|
 |
Sure.
The app I'm writing at work right now where I'm pulling data from Lotus Notes through COM. The Notes application I'm tying into contains a few environment variables that some idiot Notes developer thought would be neato to delimit with his own tag system (eg. <XX>). I've run into this a lot - where the delimiter is something like "XXXXX".
Granted, it's rare, but you asked.
I appreciate the code you contributed though.
MT
http://www.teddev.com
|
|
|
|
 |
|
 |
I created a new article for a C# version of this class. It supports delimiter strings.
http://www.codeproject.com/csharp/qstringparser_net.asp[^]
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
A Linux programmer sent me an email the other day saying he was using the STL version of the class. Cool.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Parsing the following in debug mode will cause assertion errors, ie
1. ",
2. 123,"hello",",1221"
|
|
|
|
 |
|
 |
Try the new version I posted today.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
John,
I like this class very much. It saved me the time to make a parser myself. I came to know of this class, when you posted a long time ago about users rating articles low due to factors other than technical merit. When I needed a string parser, I thought - John has posted one at CP, let me check that out first. I just rated this - Excellent.
Thanks for your contribution.
-Thomas
|
|
|
|
 |
|
 |
Yeah, it's saved me a buttload of time every time I start a new project somewhere. Happy to be of service.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Any idea as to why i'm getting this error:
VLibraryDBMS.obj : error LNK2001: unresolved external symbol "public: __thiscall CQStringParser::CQStringParser(class CString,char,char)" (??0CQStringParser@@QAE@VCString@@DD@Z)
|
|
|
|
 |
|
 |
Have you added the QStringParser.CPP file to your project?
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
 |
|
 |
1. How about when delimiter is also string , for example, "@$"?
"ab@$cd@$ef" pasrsed as "ab","cd","ef"
2. Also how about when delimiter as white space?
"ab cd" should be parsed as "ab" and "cd",
not as "ab", " ", " ", " "," ", " ","cd"
Thanks
|
|
|
|
 |