what does psz mean

D

Daniel

What does FastString(psz) mean in the following code, given the header files
I pasted below?

#include "faststring.h"
IFastString* CreateFastString (const char *psz)
{
return new FastString(psz);
}

// ifaststring.h p.19
class IFastString
{
public:
virtual void Delete(void) = 0;
virtual int Length(void) const = 0;
virtual int Find(const char *psz) const = 0;
};
extern "C"
IFastString *CreateFastString (const char *psz);

// faststring.h
#include "ifaststring.h"
class FastString : public IFastString
{
const int m_cch; // count of characters
char *m_psz;
public:
FastString(const char *psz);
~FastString(void);
void Delete(void); // deletes this instance
int Length(void) const; // returns # of characters
int Find(const char *psz) const; // returns offset
};
 
C

Carl Daniel [VC++ MVP]

Daniel said:
What does FastString(psz) mean in the following code, given the
header files I pasted below?

"pointer to zero-terminated string"

i.e. a pointer to the start of a region of memory that contains characters
followed by a 0. This is the common "C" definition of a "string".

-cd
 
D

David Lowndes

What does FastString(psz) mean in the following code, given the header files
I pasted below?

It's the call to construct a FastString object. Since you've not shown
the implementation of that constructor, it's difficult to know what it
does, but I'd guess from what you've shown that it just copies the
pointer parameter to its equivalent member variable. i.e. it may do
something like this:

void FastString::FastString(const char *psz)
{
char *m_psz = psz;
m_cch = strlen( psz );
}

psz is just a naming convention in Windows that identifies the
variable as a pointer to a null terminated string:

p = pointer
s - string
z - zero (null) terminated

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top