Table of contents
- 1. Overview
- 2. Frozen Components
- 3. Frozen Functions
- 3.1. Core Functions
- 3.2. String Functions
- 4. Frozen Interfaces
- 4.1. Core
- 4.2. Files and Directories
- 4.3. Streams
- 4.4. Primitives
- 5. XPCOM "Glue" Classes and Functions
- 5.1. Core
- 5.2. String
- 5.3. Thread Synchronization
- 6. Original Document Information
This page is the new home of the XPCOM Reference that we are migrating from here. If you are inclined to help with this migration, your help would be very much appreciated.
There may also be additional information located in Creating XPCOM Components Appendix B; it is unclear how much of the documentation in CXC overlaps with that from the to-be-migrated XPCOM reference mentioned in the last paragraph.
Please see the talk page for information about available templates and categories you should use when creating / editing pages.
Overview
This reference describes the frozen interfaces and functions provided by the XPCOM library. It also details the helper classes and functions provided by the XPCOM glue library. This reference is oriented toward extension authors and embedders of XPCOM.
NOTE: If you are working on a module in the Mozilla codebase that is compiled with MOZILLA_INTERNAL_API
, then some of these APIs--the string functions and classes in particular--may differ significantly from what you should use. See the XPCOM string guide for documentation on the string API used internally within the Mozilla codebase.
Frozen Components
These components may be accessed using the XPCOM Component Manager or Service Manager.
nsCategoryManager
- The XPCOM Category Manager.
nsDirectoryService
- The XPCOM Directory Service.
nsLocalFile
- A component implementing
nsILocalFile
.
nsObserverService
- The XPCOM Observer Service.
nsScriptableInputStream
- A component implementing
nsIScriptableInputStream
.
- XPCOM primitive components
- These components implement scriptable objects that "box" values of simple XPCOM types. They implement these interfaces:
nsISupportsCString
,nsISupportsChar
,nsISupportsDouble
,nsISupportsFloat
,nsISupportsID
,nsISupportsInterface
,nsISupportsPRBool
,nsISupportsPRInt16
,nsISupportsPRInt32
,nsISupportsPRInt64
,nsISupportsPRTime
,nsISupportsPRUint16
,nsISupportsPRUint32
,nsISupportsPRUint64
,nsISupportsPRUint8
,nsISupportsString
, andnsISupportsVoid
.
Frozen Functions
These functions are exported from the XPCOM shared library.
Core Functions
- NS_InitXPCOM2
- The
NS_InitXPCOM2
function initiates use of XPCOM in the calling process.
- NS_InitXPCOM3
- The
NS_InitXPCOM3
function initiates use of XPCOM in the calling process with support for statically defined XPCOM modules.
- NS_ShutdownXPCOM
- The
NS_ShutdownXPCOM
function terminates use of XPCOM in the calling process.
- NS_GetComponentManager
- The
NS_GetComponentManager
function returns a reference to the XPCOM Component Manager.
- NS_GetComponentRegistrar
- The
NS_GetComponentRegistrar
function returns a reference to the XPCOM Component Registrar.
- NS_GetServiceManager
- The
NS_GetServiceManager
function returns a reference to the XPCOM Service Manager.
- NS_GetMemoryManager
- The
NS_GetMemoryManager
function returns a reference to the XPCOM Memory Manager.
- NS_NewLocalFile
- The
NS_NewLocalFile
function creates an instance ofnsILocalFile
that provides a platform independent representation of a file path.
- NS_NewNativeLocalFile
- The
NS_NewNativeLocalFile
function creates an instance ofnsILocalFile
that provides a platform independent representation of a file path. You should avoid using this function if you're not 100% certain that the full file path (not just a leaf) involved is always ASCII.
- NS_Alloc
- Allocates a block of memory using the XPCOM Memory Manager.
- NS_Realloc
- Reallocates a block of memory using the XPCOM Memory Manager.
- NS_Free
- Frees a block of memory using the XPCOM Memory Manager.
String Functions
These are the low-level "string" APIs provided by XPCOM as part of its frozen API. It is often better to use one of the string classes instead of using these functions directly.
- NS_CStringContainerInit
- The
NS_CStringContainerInit
function initializes ansCStringContainer
instance for use as ansACString
.
- NS_CStringContainerInit2
- The
NS_CStringContainerInit2
function initializes ansCStringContainer
instance for use as ansACString
.
- NS_CStringContainerFinish
- The
NS_CStringContainerFinish
function releases any memory allocated by ansCStringContainer
instance.
- NS_CStringGetData
- The
NS_CStringGetData
function gives the caller read access to the string's internal buffer.
- NS_CStringGetMutableData
- The
NS_CStringGetDataMutable
function gives the caller write access to the string's internal buffer.
- NS_CStringSetData
- The
NS_CStringSetData
function copies data into the string's internal buffer.
- NS_CStringSetDataRange
- The
NS_CStringSetDataRange
function copies data into a section of the string's internal buffer.
- NS_CStringCopy
- The
NS_CStringCopy
function copies the value from onensACString
instance to another.
- NS_CStringAppendData
- The
NS_CStringAppendData
function appends data to the existing value of ansACString
instance.
- NS_CStringInsertData
- The
NS_CStringInsertData
function appends data to the existing value of ansACString
instance.
- NS_CStringCutData
- The
NS_CStringCutData
function removes a section of the string's internal buffer.
- NS_CStringCloneData
- The
NS_CStringCloneData
function returns a null-terminated, heap allocated copy of the string's internal buffer.
- NS_StringContainerInit
- The
NS_StringContainerInit
function initializes ansStringContainer
instance for use as ansAString
.
- NS_StringContainerFinish
- The
NS_StringContainerFinish
function releases any memory allocated by ansStringContainer
instance.
- NS_StringGetData
- The
NS_StringGetData
function gives the caller access to the string's internal buffer.
- NS_StringSetData
- The
NS_StringSetData
function copies data into the string's internal buffer.
- NS_StringSetDataRange
- The
NS_StringSetDataRange
function copies data into a section of the string's internal buffer.
- NS_StringCopy
- The
NS_StringCopy
function copies the value from onensAString
instance to another.
- NS_StringAppendData
- The
NS_StringAppendData
function appends data to the existing value of ansAString
instance.
- NS_StringInsertData
- The
NS_StringInsertData
function appends data to the existing value of ansACString
instance.
- NS_StringCutData
- The
NS_StringCutData
function removes a section of the string's internal buffer.
- NS_StringCloneData
- The
NS_StringCloneData
function returns a null-terminated, heap allocated copy of the string's internal buffer.
- NS_CStringToUTF16
- The
NS_CStringToUTF16
function converts the value of ansACString
instance to UTF-16 and stores the result in ansAString
instance.
- NS_UTF16ToCString
- The
NS_UTF16ToCString
function converts the value of ansAString
instance from UTF-16 to the specified multi-byte encoding and stores the result in ansACString
instance.
Frozen Interfaces
Core
nsICategoryManager
- The
nsICategoryManager
interface provides access to a data structure that holds a list of name-value pairs, called categories, where each value is a list of strings.
nsIClassInfo
- The
nsIClassInfo
interface provides information about a specific implementation class.
nsIComponentManager
- The
nsIComponentManager
interface provides methods to access factory objects and instantiate instances of classes.
nsIComponentRegistrar
- The
nsIComponentRegistrar
interface provides methods to access and modify the XPCOM component registry.
nsIFactory
- The
nsIFactory
interface allows for the creation ofnsISupports
derived classes without specifying a concrete class type.
nsIInterfaceRequestor
- The
nsIInterfaceRequestor
interface defines a generic interface for requesting interfaces that a given object might provide access to.
nsIModule
- The
nsIModule
interface must be implemented by each XPCOM component. It is the main entry point by which the system accesses an XPCOM component.
nsIMemory
- The
nsIMemory
interface represents a generic memory allocator.
nsIObserver
- The
nsIObserver
interface is a generic notification callback interface that is typically used in conjunction withnsIObserverService
.
nsIObserverService
- The
nsIObserverService
interface provides methods to add, remove, notify, and enumerate observers of various notifications.
nsIProgrammingLanguage
- The
nsIProgrammingLanguage
interface provides an enumeration of programming language identifiers.
nsIProperties
- The
nsIProperties
interface provides methods to access a map of named XPCOM object values.
nsIServiceManager
- The
nsIServiceManager
manager interface provides a means to obtain global services in an application.
nsISimpleEnumerator
- The
nsISimpleEnumerator
interface represents an enumeration of XPCOM objects and provides methods to access elements sequentially.
nsISupports
- All XPCOM interfaces inherit the
nsISupports
interface.
nsISupportsWeakReference
- The
nsISupportsWeakReference
interface is a factory interface, which produces appropriate instances ofnsIWeakReference
.
nsIWeakReference
- The
nsIWeakReference
interface represents a proxy for an XPCOM object. It allows a consumer to hold an indirect, non-owning reference to an XPCOM object.
Files and Directories
nsIFile
- The
nsIFile
interface represents a file or directory location in a platform-independent manner.
nsILocalFile
- The
nsILocalFile
interface represents a file or directory location in a platform-independent manner that is accessible on the local filesystem. It extends nsIFile.
nsIDirectoryService
- The
nsIDirectoryService
interface provides methods to initialize and configure a directory service instance.
nsIDirectoryServiceProvider
- The
nsIDirectoryServiceProvider
interface is used by the Directory Service to get file locations.
nsIDirectoryServiceProvider2
- The
nsIDirectoryServiceProvider2
interface is used by the Directory Service to get an enumeration of file locations.
Streams
nsIInputStream
- The
nsIInputStream
interface represents a readable data source.
nsIOutputStream
- The
nsIOutputStream
interface represents a writable data sink.
nsIScriptableInputStream
- The
nsIScriptableInputStream
interface provides scriptable access to ansIInputStream
instance.
Primitives
nsISupportsPrimitive
- The
nsISupportsPrimitive
interface serves as a base interface for all of thensISupports*
family of interfaces.
nsISupportsPRBool
- The
nsISupportsPRBool
interface provides scriptable access for boolean values.
nsISupportsChar
- The
nsISupportsChar
interface provides scriptable access for single character values (often used to store an ASCII character).
nsISupportsPRInt16
- The
nsISupportsPRInt16
interface provides scriptable access for 16-bit signed integers.
nsISupportsPRInt32
- The
nsISupportsPRInt32
interface provides scriptable access for 32-bit signed integers.
nsISupportsPRInt64
- The
nsISupportsPRInt64
interface provides scriptable access for 64-bit signed integers.
nsISupportsPRUint16
- The
nsISupportsPRUint16
interface provides scriptable access for 16-bit unsigned integers.
nsISupportsPRUint32
- The
nsISupportsPRUint32
interface provides scriptable access for 32-bit unsigned integers.
nsISupportsPRUint64
- The
nsISupportsPRUint64
interface provides scriptable access for 64-bit unsigned integers.
nsISupportsPRUint8
- The
nsISupportsPRUint8
interface provides scriptable access for 8-bit unsigned integers.
nsISupportsDouble
- The
nsISupportsDouble
interface provides scriptable access for double-precision floating-point values.
nsISupportsFloat
- The
nsISupportsFloat
interface provides scriptable access for single-precision floating-point values.
nsISupportsPRTime
- The
nsISupportsPRTime
interface provides scriptable access for PRTime values.
nsISupportsCString
- The
nsISupportsCString
interface provides scriptable access for ASCII character strings.
nsISupportsString
- The
nsISupportsString
interface provides scriptable access for Unicode character strings.
nsISupportsVoid
- The
nsISupportsVoid
interface provides scriptable access for generic pointers. values.
nsISupportsID
- The
nsISupportsID
interface provides scriptable access for boolean values.
nsISupportsInterfacePointer
- The
nsISupportsInterfacePointer
interface provides scriptable access for XPCOM objects.
XPCOM "Glue" Classes and Functions
These classes and functions are provided to simplify the use of XPCOM from C++. They are not part of the frozen XPCOM API, which means that they may evolve over time. When these classes are used by a component, it may be necessary to link the component against the XPCOM glue library.
Core
- nsCOMPtr
- This utility class simplifies managing XPCOM interface references from C++ code.
- nsMemory
- The
nsMemory
class provides static helper routines to manage memory. These routines allow easy access to XPCOM's globalnsIMemory
implementation without having to go through the service manager to get it.
- nsSupportsWeakReference
- Inherit from this C++ class to add canonical support for
nsISupportsWeakReference
.
String
- nsACString
- The
nsACString
abstract class represents a character string composed of single-byte storage units. This class is typically used to represent ASCII or UTF-8 character arrays.
- nsAString
- The
nsAString
abstract class represents a character string composed of double-byte storage units. This class is typically used to represent Unicode character arrays.
- nsEmbedString
- The
nsEmbedString
concrete class provides a way to construct ansAString
object that allocates null-terminated storage.
- nsEmbedCString
- The
nsEmbedCString
concrete class provides a way to construct ansACString
object that allocates null-terminated storage.
- nsString
- ...
- nsCString
- ...
- nsLiteralCString
- ...
- nsLiteralString
- ...
- getter_Copies
- ...
- Substring
- ...
- StringHead
- ...
- StringTail
- ...
- EmptyString
- ...
- EmptyCString
- ...
Thread Synchronization
See the page here.
Original Document Information
- Author: Darin Fisher
- Last Updated Date: 2005/01/20
- Copyright Information: Copyright © 2004-2005