|
why? Is it faster? why are SqlGetData slow?
|
|
|
|
|
Hello everyone,
I have a little problem that I was hoping someone could help me out with. I have a data file (created by using serialization) that I want to read into a new program. Problem is, the new program class name is the same as the old one (and I can't change it since the code was done by a third-party). I want to use my old class to read the data in, then save it to the new class.
So, I created a new class (let's call it CAlar1, since the original class was CAlarm and I thought the class name length should be the same) and tried to read the file in, but after serializing the class, all the data is messed up. Since the class name is different, it doesn't seem to be reading the file correctly.
Is there any way around this? I would like to read the old data in, convert it to the new class, and save it back, so short of decoding the binary file format, is there anything else I can try?
Regards,
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Brigg Thorp wrote:
Is there any way around this? I would like to read the old data in, convert it to the new class, and save it back, so short of decoding the binary file format, is there anything else I can try?
If you have a class with the same name as a third-party utility you can wrap your class around a namespace, thus:
using CAlarm;<br />
using MyClass::CAlarm;
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
If you have a class with the same name as a third-party utility you can wrap your class around a namespace, thus:
using CAlarm;
using MyClass::CAlarm;
Not exactly sure what you mean by this. Also, don't know if I explained the situation clearly.
I have a class CAlarm done by a third-party company. Let's say that it has 12 variables serialized to a file. I have another class CAlarm (which I renamed to CAlar1 so I could compile my project) which has 8 variables serialized to a file. What I want to do is read the 8 variable class in, then add that data to the 12 variable class (supplying defaults for the additional 4 variables).
The 12 variable class was originally written by us, however another company changed it, but didn't update the version number that is serialized to the file (so both files have a version number of 1). So, I can't easily update the 12 variable class with a new version number (there are already files in use), then have a variable read in either the 8 variable file or the 12 variable file depending on the version. I have the code for both classes, so I'm not sure what the next step to take is.
Regards,
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
|
Use a DLL to make that work...
|
|
|
|
|
Hi, everyone!
I often puzzled about when to use const_iterator of vector
and when to use size_type of vector.
For example, in the following piece of code, we should use
const_iterator instead of size_type.
I want to know whether there are some concrete rules? Easy to
remember ones.
Source Code:
--------
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string>::const_iterator i;
vector<string> Buffer;
Buffer.push_back ("Hello");
i = Buffer.begin();
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
You use size_type when you work with an index into the vector.
For access, you use operator[]
You use an iterator as a pointer into the vector.
For access you use operator->
So, in one sentence: They do similar things, but are absolutly not interchangeable.
I hope this helped
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
I have never used operator -> with const_iterator of
vector. I have just used * operator on it. Can you
show me an example about how to use operator -> with
const_iterator of vector?
regards,
George
|
|
|
|
|
The -> operator is used when the iterator references a struct or class . It's a short-hand notation for combination of * and . :
iter->member is same as
(*iter).member
|
|
|
|
|
Thanks, markkuk buddy!
I think when use const_iterator, the operator -> is used on
the iterator. And when use size_type, the operator [] is used
on the vector itself. So the objects they are used on are different.
Am I correct?
regards,
George
|
|
|
|
|
I have divided one of my Visual Studio projects into "subsystems" using folders to make it easier to navigate between logically seperate subsystems. But my problem is that after a while these folders disappeared. It really annoys me because it takes quite a long time to sort my classes into these folders. Is this a known problem and is there anything I can do to solve the problem?
|
|
|
|
|
The folder information is stored in the project's .opt file, so you'll need to protect if from beeing removed or overwritten. Or, if you're using a version control system, you could have it checked in, checking it out when you make changes to the class tree...
I don't know why they disappear, but it's bothering me as well.
|
|
|
|
|
Thanks that helped i will try and protect that .opt file by moving it into sourcesafe.
|
|
|
|
|
This is no good. This is a VS6 bug, and I had to surrender with it. Now I divide a workspace into subprojects when I want to have my classes separated/grouped.
Regards,
BB
|
|
|
|
|
Hi,
I wanted to use the RTF/CRichEditCtrl as a kind of report system, where the reports are generated from templates of rtf files. Consider a simple application, that needs to fill out a predefined form with some application dependant values.
A first simple solution would be to search and replace Tags within the RTF file with the computed values.
A better solution would be to use the field tag from the RTF specification directly. For example the author field from a word document would look like:
{\field{\*\fldinst
{ AUTHOR \\* MERGEFORMAT }}{\fldrslt {Dirk}}}
where fldinst is the specific field instruction and fldrslt is the latest evaluated result.
Unhappily the CRichEditCtrl does not evaluate internal fields (like author) either, and I couldn't find any Interface in the ITextDocument specification to access the fields of the document.
Does anybody know how to reevaluate the contents of fields programmatically? Something like a callback function with the fied instruction (fldinst) and the return value is the evaluated result? Another possibility would be to reparse the complete document again and aply the evaluated values into the result field (fldrslt) and then feed the document back to the Ctrl.
Any ideas / code?
Thanks
Dirk
|
|
|
|
|
Hi,
does somebody know how to rename an existing project??
Thanks, Mark
|
|
|
|
|
Make a search for vsrename here on CP.
[edit]
Ouuahh connection is fast today, so you will even get a link
Click here[^]
[/edit]
~RaGE();
|
|
|
|
|
Do you realy want to change the project name of just the .exe name? If just the .exe name then (1)select project settings (2)select like tab (3)change the output file name for both debug and release versions (4)change the name(s) in version info. resource and any where else where is might be stored (such as your about box and string table, etc...)
I just did the above today, since the internal project name was not acceptable for a released .exe name.
|
|
|
|
|
Hi.
Got a little question, i need to change the m_pszHelpFilePath member to another value.
Let's assume i have a dialog where i can click english or dutch help file.
If english, m_pszHelpFilePath = appname.HLP
if dutch, m_pszHelpFilePath = appnameD.HLP
(path need to be the path where the exe file is executing)
Does anyone know how to do this?
Greetings
Jens
|
|
|
|
|
Try this (MSDN):
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(_T("d:\\somedir\\myhelp.hlp"));
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yeah i found that too, but how can i know the current directory where the application is running?
And can i access this member everywhere?
|
|
|
|
|
This will give you the current directory where the application is running.
GetModuleFileName ( NULL, strPath, MAX_PATH );
m_pszHelpFilePath is a public member of CWinApp so you can access this member anywhere this way:
AfxGetApp()->m_pszHelpFilePath
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
yeah i've been trying it out:
char path[256];
GetModuleFileName(NULL, path, 256);
CString strFilePath = path;
int idx = strFilePath.ReverseFind( '\\' );
strFilePath.SetAt( idx, '\0' );
AfxMessageBox(strFilePath);
displays "c:\source\myprogram\debug"
free((void*)app->m_pszHelpFilePath);
app->m_pszHelpFilePath=_tcsdup(strFilePath);
it doesn't work .. he still takes the normal path but i think there is a problem with the '\'
i think he has to display "c:\\source\\myprogram\\debug"
Am i right, and so yes how can i easily fix this problem?
...
AfxMessageBox(strFilePath);
strFilePath += "\\MYPROGRAMF.HLP";
AfxMessageBox(strFilePath);
Why doesn't he add "\\MYPROGRAMF.HLP" to the CString????
i totally don't get it anymore
|
|
|
|
|
strFilePath in your program is the path the exe file. If your help file is there two then you don't really need the whole path. strFilePath = "helpfile.hlp". But if you want to proceed with the exe path then you need c:\source\myprogram\debug\helpfile.hlp". In your program all you have is c:\source\myprogram\debug.
Also check CWinApp::WinHelp
char szPath[ MAX_PATH + 1 ];
GetModuleFileName( NULL, szPath, MAX_PATH );
CString strPath = szPath;
int idx = strPath.ReverseFind( '\\' );
length_of_exe_file = 10;
if( idx != -1 )
{
strPath.Delete( idx+1, length_of_exe_file );
}
strPath += "helpfile.hlp";
AfxMessageBox( strPath );
free((void*)AfxGetApp()->m_pszHelpFilePath);
AfxGetApp()->m_pszHelpFilePath=_tcsdup(strPath);
JensB wrote:
it doesn't work .. he still takes the normal path but i think there is a problem with the '\'
i think he has to display "c:\\source\\myprogram\\debug"
\\ is a way for the compiler to read '\'. '\' is called an escape sequence I think. I might be wrong about the name.
// Afterall I realized that even my comment lines have bugs
|
|
|
|