what does psz mean

  • Thread starter Thread starter Daniel
  • Start date Start date
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
};
 
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
 
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
 
Back
Top