|
If you had
wchar_t fileBuffer[] = "youfriend你好朋友";
You could have:
typedef std::pair<wchar_t*,> Word;
std::vector<word> words;
words.push_back(std::make_pair(fileBuffer, fileBuffer+3);
words.push_back(std::make_pair(fileBuffer+3, fileBuffer+9);
words.push_back(std::make_pair(fileBuffer+9, fileBuffer+11);
words.push_back(std::make_pair(fileBuffer+11, fileBuffer+13); ?
That could be less overhead than std::string, possibly.
Alternatively, you could use something like a trie[^] to hold all the words?
What's the intent, anyway - why are you building this list of words?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am doing a program about Full Text Search
English is easy to segment
but Chinese is complicated
First I should separate text that to make Chinese and English text to two vector
Second do segment to each text and building index for search
I have to consider about speed ,the size of index file and Search speed
some difficulty I've already solved
I wanna do it well
Thank you so much
|
|
|
|
|
Have a feeling that it is caused by the automatic growth of strings / vector.
You can use swap to trim the vector to minimum size. Guess the same thing should be possible with strings.
vector<string>(trim).swap(trim);
Herb Sutter: The Incredible Shrinking vector
It is even better to resize the strings / vectors to their expected size from the start.
|
|
|
|
|
Yes
That's the problem
I'll try later
Thank you so much for your advise
|
|
|
|
|
Suppose that we've defined (for example) OnAppAbout() function in CMyAppView to be called when the user clicks the About item from Help menu. Now if we define it in both CMainFrame and CMyAppDoc as well, which of them is called when the user clicks the menu item?
|
|
|
|
|
Why don't you try it & see? It's not like you can break anything...it's just software.
This article[^] by Paul DiLascia (RIP) could also help.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I wonder if is there a way to change the size and position of a CView derived window within a SDI application? If not why?
|
|
|
|
|
Isn't the view size going to be tied to the main frame size in an SDI app?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
OK - first hit for "SDI resize view" on Google is this CodeProject article[^] - does that help?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,,
I need this info.
I am interacting with MSMQ using VC++.
I am able to send messages. But i am not able to send really really large messages, really close to 4 MB but not more than that.
I guess the issue here is not with MSMQ, but to convert CString to wchar_t*.
I am using this code,
int length = data.GetLength(); // data is CString
USES_CONVERSION;
wchar_t *pwcharMessageBody = T2W(data.GetBuffer()); //stack overflow,This line fails for large string
data.ReleaseBuffer();
This is working for most cases. But not working for very large string size.
Any help will be great.
Thanks,
Saleem
|
|
|
|
|
Use MultiByteToWideChar with a large buffer.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
If you want to stick with the handy ATL conversion mechanisms, and you're using Visual Studio 2003, 2005 or 2008, check out this page[^] and use a CT2W object - you should just be able to add a C to your current T2W usage.
The Cx2y objects default to using an internal buffer for 64 byte strings, but allocate a buffer with malloc for larger strings, which is probably just what you want.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks,,,but there seems to be a problem.
Code compiles fine.
But the wchar_t* is blank.
this is my code....
wchar_t *pwcharMessageBody = CT2W(data);
tried this too..
wchar_t *pwcharMessageBody = CT2W(data.GetBuffer());
No luck.
Any help will be great.
Saleem
|
|
|
|
|
Ah - that's because the CT2W object goes out of scope.
Try this:
CT2W pwcharMessageBody(data);>/pre>
A CT2W has a string conversion operator, it's just that now that the lifetime of pwcharMessageBody defines the conversion buffer lifetime.
<div class="ForumSig">Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p</div>
|
|
|
|
|
Actually it is a limit in MSMQ, so there is no problem in converting large char-arrays.
Sending MSMQ Messages larger than 4 Mb. causes exception
You either have to chop the message up in smaller pieces, or maybe perform compression before sending to MSMQ (Requires the opposite part is able to decompress the message again).
|
|
|
|
|
Hi there.
While using a component, I ma getting above mentioned error message.
Just FYI, I have included .lib file under Linker/Inputs/Additional Dep... section. Also, have copied .dll file amd have also added .h file under the project.
Any pointers/suggestions will be highly appretiated.
Thanks
Pankaj
|
|
|
|
|
I guess the error message in the subject line is not complete.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Here we go...
1>LoggingManager.obj : error LNK2019: unresolved external symbol "public: __thiscall CDataAccessManager::CDataAccessManager(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (??0CDataAccessManager@@QAE@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) referenced in function "private: __thiscall CLogger::CLogger(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (??0CLogger@@AAE@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
1>E:\PankajB\DATALAYER\Debug\DATALAYER.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
Is it possible that the component you are using was compiled using non-Unicode strings and you are using Unicode strings in your project?
If the header files just mentions CString, that could happen.
Try removing the 'UNICODE:-UNICODE' part from the pre-processor macros section of your project properties and rebuilding.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You are creating an object of CDataAccessManager in the constructor of CLogger , but it cannot find the constructor that takes a CString as parameter.
Are you export CDataAccessManager as a class from a DLL?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes. I have exported this class.
|
|
|
|
|
Are you sure the exe is using the latest lib file?
You probably added the constructor later and forgot to copy the lib file!
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes, brother. I have just created one. Let me create a new one.
One more point - I am using all the DEBUG version files. I dont this that makes any differenece. Will be back to you aftar testing new lib.....
|
|
|
|
|
Same problem...
|
|
|
|