|
Stick an __inline in there and that ought to do it.
class cl
{
public:
__inline CString short_l(int i){ return FunctionWithADisturbingLongName(i);}
}
|
|
|
|
|
Function pointer or wrap the big named func in a small one.
Oh yeah, function pointers suck in C++. Awfull damn syntax.
==============================
Nothing to say.
|
|
|
|
|
Me think that it is a bad idea.
Your code will be peppered with function calls to short and/or abbreviated method names that will not reflect what it actually do; and the user (other developers) will need to look at the documentation to know what it should be doing.
Watched code never compiles.
|
|
|
|
|
oh, I agree that this would be bad practice. Basically, you have a descriptive function name that makes the code reading for understanding far easier. But instead, you'll have code that uses short, cryptic names because it's easier to type (unless you're letting the wizard auto-complete function names)
There's a reason that .NET Obfuscation routines create names like "N1", "N2", etc. It's because it makes the code harder to read and understand. Why do that on purpose to code you have to maintain.
|
|
|
|
|
Agree too... unless the short names still provide sufficient information to make it readable, although if that's the case... why keep the long names at all (unless it's a library of sorts)...
|
|
|
|
|
I too agree with all of that.
|
|
|
|
|
There are several ways
1. #define works, if you choose a reasonably unique name, but it clutters the global namespace and therefore not a good idea.
2. declaring a second function that wraps the first adds code cluttering in your original class
3. a function pointer could work, but involves awkward syntax both for defining the pointer and calling the function
4. a function object would add quite a lot of code, but requires neither changing your original class nor dereferencing to invoke the function:
class shortname {
public:
shortname(class c1* p) : pclass(p) {}
CString operator()(int i) { return pclass->FunctionWithADisturbingLongName(i); }
private:
class c1* pclass;
};
void foo() {
c1 test;
shortname(&test);
CString result = shortname(1);
}
|
|
|
|
|
Hi all.
I need to develop a program that manage a FAT or NTFS partition. It should directly access and analyze sectors in partition for its management, and it should can read files list, read file data,create new file and write data to that file.
I search web very much but not found any open source app that match that I need.
Is there any open source app that manage FAT or NTFS partition?
If you can please help me.
excuse me for bad English.
Thanks a'lot.
|
|
|
|
|
A_Fa wrote:
Is there any open source app that manage FAT or NTFS partition?
See GParted[^]
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
hi all,
i am using CDatabase to open the database and its function ExecuteSQL to execute the query.
here how can i get all column name list of current database.
please help me for this.
thanks in advance.
|
|
|
|
|
I suspect there is some SQL command for this but it's nothing to do with C++; try asking your question in the Database forum.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Hi,
can someone please have a look at this:
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/01187549-46ce-4d9a-bd08-e1b478daf7ed
I am a little desperate on that issue, because i dont know how to pass the interface to the function.
On Vista+ it is the "CreateVssBackupComponentsInternal" in vssapi.dll
On XP it is the "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" in vssapi.dll
Both expect a IVSSBackupComponents Interface, but with different guids (microsoft changed the interface from XP to vista, so they are incompatible) and slightly different implementation, which of course made the interface mutually exclusive on the platforms. As long as i use the implementation with the known guid from the headers on vista, seven and eight, all is perfectly fine, but the function call on the XP system does not accept my interface and says that the IID
"{A4B0621E-CA3F-34A1-AD56-E9C4A2F56E8D}" does not support the interface (HRESULT: 0x80004002 (E_NOINTERFACE)). So i cant use the implementation with the "665C1D5F-C218-414D-A05D-7FEF5F9D5C86" on the XP function on the vssapi.dll
The definitions can be found in the Volume Shadow Copy Service SDK 7.2 here:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23490[^]
Thanks in advance
K.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Visit: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
I'm a beginner with VC++. I tried to do program to communicate with COM port of PC but I failed to use the MSComm lib. After that, I changed to use the "Serial library for VC++" which was written by Ramon de Klein but now I had an error I dont know how to solve.
The following sentence is the error:
"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1512;}\viewkind4\uc1\pard\f0\fs20 H:\\Program Files\\Microsoft Visual Studio\\MyProjects\\TestXbee\\TestXbeeDlg.cpp(130) : error C2664: 'Open' : cannot convert parameter 2 from 'class CTestXbeeDlg *const ' to 'unsigned long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
}"
Now is the part of my program which informed about that error
"CString m_strComPort;
m_strComPort.Format(TEXT("COM2"));
CSerial port;
if (port.Open(m_strComPort,this) != ERROR_SUCCESS
{
AfxMessageBox(TEXT("Unable to open COM"),MB_ICONSTOP | MB_OK);
GetParent()->PostMessage(WM_CLOSE);
return 0;"
Thank you very much
|
|
|
|
|
I believe the second parameter to the Open function is a window handle.
You're trying to pass it a CWnd* .
Try this - port.Open(m_strComPort, m_hWnd);
|
|
|
|
|
It doesnt work. 
|
|
|
|
|
Please make your posts readable by putting code extracts within <pre> tags, indenting the code and removing unnecessary control or meta characters. Something like the following:
This uses <pre lang="c++"></pre>
CString m_strComPort;
m_strComPort.Format(TEXT("COM2"));
CSerial port;
if (port.Open(m_strComPort,this) != ERROR_SUCCESS
{
AfxMessageBox(TEXT("Unable to open COM"),MB_ICONSTOP | MB_OK);
GetParent()->PostMessage(WM_CLOSE);
return 0;
}
This uses <pre lang="text"></pre>
H:\\Program Files\\Microsoft Visual Studio\\MyProjects\\TestXbee\\TestXbeeDlg.cpp(130) : error C2664: 'Open' : cannot convert parameter 2 from 'class CTestXbeeDlg *const ' to 'unsigned long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
As to your error message, the Open() function requires some value which is an unsigned long not a pointer to your enclosing class. You should check the documentation for the Open() function for specific details.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
So give the Open() func the correct parameter.
I havent a clue what it is, Ramions API doesnt have a second param, other APIs have baudrate, so look at the documentation.
==============================
Nothing to say.
|
|
|
|
|
How to use that library if it is so bad documented?
We do alot of serial programing. At the end it pays 10x using a good commercial library with technical support. We successfuly replaced MSComm with SuperCom ActiveX and it also solved us a lot other issues we had with Bluetooth devices.
|
|
|
|
|
I'm building a WCHAR Array, of server names to write to a REG_MULTISIZE Registry Key, But I'm unsure if I did the right thing.
The rule was a ServerName\0ServerName\00, but I get
"﷽﷽ꮫꮫꮫꮫﻮﻮﻮﻮﻮﻮDELLC521-01\SQLEXPRESSDELLC521-01\SQLEXPRESSWSA1\SQLEXPRESSDELL760\SQLEXPRESS2"
I'm not sure if my \0 went in, and I need to fix the prefix
WCHAR *pzServerNames = new WCHAR[0];
for ( int i = 0; i < sqlCount; ++i ) {
pzServerName = sqlSrvCollection[i];
wcsncat(pzServerNames, pzServerName, wcslen(pzServerName) );
wcsncat(pzServerNames, L"\0", wcslen(L"\0") );
}
_wcsncat_l(pzServerNames, L"\0\0", wcslen(L"\0\0"), NULL);
|
|
|
|
|
I guess first of all you're lucky it didn't crash since you allocated an array of 0 length.
Mark Salsbery
|
|
|
|
|
I guess that wasn't a good idea. I think I'm going to abandon that idea, and change the registry program to add 1 server name at a time. Read the key, and if the name is not there, then add the name and write the key back.
|
|
|
|
|
Try this:
int length = 0;
for ( int i = 0; i < sqlCount; ++i )
{
length += wcslen(sqlSrvCollection[i]);
length += 1; }
WCHAR* pzServerNames = new WCHAR[length + 1]; PWSTR pNext = pzServerNames; for ( int i = 0; i < sqlCount; ++i )
{
wcscpy_s(pNext, length, sqlSrvCollection[i]); int nlen = wcslen(sqlSrvCollection[i]); pNext += nlen; *pNext++ = L'\0'; length -= nlen + 1; }
*pNext = L'\0';
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yeah, I thought I was going to have to do a per-calculation. I changed the format of the program, and opted for adding the server name 1 at a time. So when I add the name to the collection, I add the name to the registry key, which is multi-size. Sort of like the MimeMap Program, in which I read the key, look for a duplicate, if no duplicate, add the name, write the key back.
I will take your wisdom, and mix the 2 together. I wrote this yesterday, which is better than the the one I had in question. I know it has issues, in which I will straighten out today, on this rainy day.
I'm going to dump the wcsncmp for a straight value = value.
TCHAR szAddServerName[120];
WCHAR *pzServerNames = NULL;
int idx = wcslen(pzServerName);
for (int i = 0; i < idx; i++) {
szAddServerName[i] = pzServerName[i];
}
szAddServerName[idx] = L';';
szAddServerName[idx+1] = L'\0';
pzServerNames = CA_Registry::_get_Enumerated_SQLServers();
int iCompare;
wchar_t *token1, *nextToken;
wchar_t seps[] = L";";
token1 = wcstok_s(pzServerNames, seps, &nextToken);
do {
iCompare = wcsncmp(szAddServerName, token1, wcslen(szAddServerName)-1 );
if (iCompare != 0) {
wcsncat(pzServerNames, L";", wcslen(L";") );
wcsncat(pzServerNames, szAddServerName, wcslen(szAddServerName)+1 );
}
token1 = wcstok_s(NULL, seps, &nextToken);
if (token1 == NULL)
break;
} while (TRUE);
int iLength = wcslen(pzServerNames)+1;
pzServerNames[iLength+1] = L'\0';
WCHAR *szServerNames = new WCHAR[iLength+1];
wcsncpy_s(szServerNames, pzServerNames, wcslen(szServerNames) );
szServerNames[iLength] = L'\0\0';
|
|
|
|
|
I give your suggestion a spin, I don't understand this line. I know the pNext++ is a method to add a wchar to a const, but it goes backwards.
pNext += nlen; // The pNext goes Null
*pNext++ = L';'; // I wanted to add a ; to tokenize
*pNext++ = L'\0'; // takes a wchar off the front
int sql_Count = sqlSrvCollection.Count();
int length = 0;
for ( int i = 0; i < sql_Count; ++i )
{
length += wcslen(sqlSrvCollection[i]);
length += 2;
}
WCHAR* pzServerNames = new WCHAR[length + 1];
PWSTR pNext = pzServerNames;
for ( int i = 0; i < sql_Count; ++i )
{
wcscpy_s(pNext, length, sqlSrvCollection[i]);
int nlen = wcslen(sqlSrvCollection[i]);
pNext += nlen;
*pNext++ = L';';
*pNext++ = L'\0';
length -= nlen + 1;
}
*pNext = L'\0';
|
|
|
|