Previous Contents Index Next |
Setup Util Programmer's Guide |
Chapter 26 Nsdefs.h Library Reference
This chapter describes nsdefs.h, the library containing general Netscape C++ classes and definitions. It is divided into the following sections:
NSString Class
Constructors
Constructs an empty NSString:
Constructs string from s (up to length chars):
NSString(const char *s, int length);
Copies one NSString to another:
Assignment
NSString & operator = (const char *);
NSString & operator = (const NSString &);
Comparison
int operator == (const char *m) const;
int operator != (const char *m) const;
int operator == (const NSString & m) const;
int operator != (const NSString & m) const;
Get char * from String
virtual const char *data() const
{ return _data; }
operator const char * () const
{ return _data; }
virtual long length() const
{ return _length; }
Append Constructor
NSString (const char *s1, long l1, const char *s2, long l2);
Concatenation Functions
friend NSString
operator + (const NSString &, const NSString &);
friend NSString
operator + (const char *, const NSString &);
friend NSString
operator + (const NSString &, const char *);
Constructors/Deconstructors
NVPair();
read
void read(const char *fileName);
clear
Empties out this Name/Value pair
Assignment Operators
NVPair & operator = (const NVPair &);
Set and Get the ID of this NVPair
In general, the ID is not set except when the NVPair takes on a section name as an ID.
Put a Timestamp on this Block
const char *timeStamp() const;
get
Gets the value string associated with name.
const char *get(const char *name) const;
set
Sets the value of name to value. If name does not exist, it will be created. If name already exists, its value will be overwritten.
void set(const char *name, const char *value);
void set(const char *name, const NSString &value);
void set(const char *name, int value);
void set(const char *name, unsigned int value);
void set(const char *name, long value);
void set(const char *name, unsigned long value);
void set(const char *section, const char *name, const char *value);
void set(const char *section, const char *name, const NSString
&value);
void set(const char *section, const char *name, long value);
A list is a name containing multivalues
getListItem
Gets the nth value in list name.
const char *getListItem (const char *name, int nth) const;
getListItems
Gets all the values in list name.
char **getListItems(const char *name) const;
freeListItems()
Discards list name.
static void freeListItems(char **items);
inList
Does list name contain a certain value?
Bool inList(const char *name, const char *value) const;
listExists
Does list name exist?
Bool listExists(const char *name) const;
add
Adds value to list. If list does not exist, it is created.
void add (const char *list, const char *value);
void add (const char *list, const NSString &value);
void add (const char *list, const char **values);
void add (const char *section, const char *list, const char *value);
void add (const char *section, const char *list, const NSString &value);
void add (const char *section, const char *list, const char **values);
void delList(const char *name);
void delListItem(const char *name, const char *item);
Name Traversal Functions
int numName() const;
int numListItems(const char *list) const;
name
Gets the nth name as stored in NVPair.
const char *name(int nth) const;
list
Gets the name of list nth as stored in NVPair.
const char *list(int nth) const;
numSections
Gets the number of the sub-Name/Value pairs
getSection
Gets the nth sub-NVPair. Gets the sub-NVPair identified by name.
NVPair * getSection(const char *name);
addSection
Adds subBlock into this NVPair as a sub-NVPair. If the subBlock does not exist, it is created. Otherwise the new one is merged with the old one.
void addSection(const char *name, NVPair *subBlock);
createSection
Creates a section in the current NVPair if one does not yet exist. Returns a pointer to the section.
NVPair *createSection(const char *name);
void rename(const char *oldLabel, const char *newLabel);
remove
Deletes a name/value pair. Use delList to delete a list.
void remove(const char *label);
Internationalization Conversion Functions
toUTF8
Converts a string to UTF-8. Specifying a label performs the conversion on that label only. Otherwise, the whole NVPair structure is converted.
void toUTF8(const char *label=0);
toLocal
Converts a string from UTF-8 to this locale. Specifying a label performs the conversion on that label only. Otherwise, the whole NVPair structure is converted.
void toLocal(const char *label=0);
setFormat
Sets the delimeters for name/value pairs in the written file.
which = 0 - <sp> for name/value, ':" for list
which = 1 - '='
which = 2 - ':'
void setFormat(int which);
write
Writes this block to fileName . Use setFormat to set the format in which to write blocks. Specify no arguments to write this block out to the file from which it was previously read. Returns -1 on any error.
int write(const char *fileName) const;
Previous Contents Index Next
Copyright (C) 2005 Red Hat, Inc. All rights reserved.
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/
Last Updated September 21, 2001