COleVariant (clase)COleVariant Class
Encapsula el tipo de datos VARIANT .Encapsulates the VARIANT data type.
SintaxisSyntax
class COleVariant : public tagVARIANT
MiembrosMembers
Constructores públicosPublic Constructors
NOMBREName | DescripciónDescription |
---|---|
COleVariant:: COleVariantCOleVariant::COleVariant | Construye un objeto COleVariant .Constructs a COleVariant object. |
Métodos públicosPublic Methods
NOMBREName | DescripciónDescription |
---|---|
COleVariant:: AttachCOleVariant::Attach | Adjunta una variante a un COleVariant .Attaches a VARIANT to a COleVariant . |
COleVariant:: ChangeTypeCOleVariant::ChangeType | Cambia el tipo de variante de este COleVariant objeto.Changes the variant type of this COleVariant object. |
COleVariant:: ClearCOleVariant::Clear | Borra este objeto COleVariant .Clears this COleVariant object. |
COleVariant::D EtachCOleVariant::Detach | Desasocia una variante de COleVariant y devuelve la variante.Detaches a VARIANT from a COleVariant and returns the VARIANT. |
COleVariant:: GetByteArrayFromVariantArrayCOleVariant::GetByteArrayFromVariantArray | Recupera una matriz de bytes de una matriz de variantes existente.Retrieves a byte array from an existing variant array. |
COleVariant:: SetStringCOleVariant::SetString | Establece la cadena en un tipo determinado, normalmente ANSI.Sets the string to a particular type, typically ANSI. |
Operadores públicosPublic Operators
NombreName | DescripciónDescription |
---|---|
COleVariant:: Operator LPCVARIANTCOleVariant::operator LPCVARIANT | Convierte un COleVariant valor en LPCVARIANT .Converts a COleVariant value into an LPCVARIANT . |
COleVariant:: Operator LPVARIANTCOleVariant::operator LPVARIANT | Convierte un COleVariant objeto en LPVARIANT .Converts a COleVariant object into an LPVARIANT . |
COleVariant:: Operator =COleVariant::operator = | Copia un COleVariant valor.Copies a COleVariant value. |
COleVariant:: Operator = =COleVariant::operator == | Compara dos COleVariant valores.Compares two COleVariant values. |
COleVariant:: < < (operador),>>COleVariant::operator <<, >> | Envía un COleVariant valor a CArchive o CDumpContext y escribe un COleVariant objeto de CArchive .Outputs a COleVariant value to CArchive or CDumpContext and inputs a COleVariant object from CArchive . |
ObservacionesRemarks
Este tipo de datos se utiliza en la automatización OLE.This data type is used in OLE automation. En concreto, la estructura DISPPARAMS contiene un puntero a una matriz de estructuras variantes.Specifically, the DISPPARAMS structure contains a pointer to an array of VARIANT structures. Una DISPPARAMS
estructura se utiliza para pasar parámetros a IDispatch:: Invoke.A DISPPARAMS
structure is used to pass parameters to IDispatch::Invoke.
Nota
Esta clase se deriva de la VARIANT
estructura.This class is derived from the VARIANT
structure. Esto significa que puede pasar un COleVariant
en un parámetro que llama a para un VARIANT
y que los miembros de datos de la VARIANT
estructura son miembros de datos accesibles de COleVariant
.This means you can pass a COleVariant
in a parameter that calls for a VARIANT
and that the data members of the VARIANT
structure are accessible data members of COleVariant
.
Las dos clases MFC relacionadas COleCurrency y COleDateTime encapsulan los tipos de datos Variant Currency ( VT_CY
) y Date ( VT_DATE
).The two related MFC classes COleCurrency and COleDateTime encapsulate the variant data types CURRENCY ( VT_CY
) and DATE ( VT_DATE
). La COleVariant
clase se utiliza exhaustivamente en las clases DAO; vea estas clases para el uso típico de esta clase, por ejemplo, CDaoQueryDef y CDaoRecordset.The COleVariant
class is used extensively in the DAO classes; see these classes for typical usage of this class, for example CDaoQueryDef and CDaoRecordset.
Para obtener más información, vea las entradas Variant, Currency, DISPPARAMSy IDispatch:: Invoke en el Windows SDK.For more information, see the VARIANT, CURRENCY, DISPPARAMS, and IDispatch::Invoke entries in the Windows SDK.
Para obtener más información sobre la COleVariant
clase y su uso en la automatización OLE, vea "pasar parámetros en la automatización OLE" en el artículo automatización.For more information on the COleVariant
class and its use in OLE automation, see "Passing Parameters in OLE Automation" in the article Automation.
Jerarquía de herenciaInheritance Hierarchy
tagVARIANT
COleVariant
RequisitosRequirements
Encabezado: afxdisp.hHeader: afxdisp.h
COleVariant:: AttachCOleVariant::Attach
Llame a esta función para asociar el objeto Variant dado al COleVariant
objeto actual.Call this function to attach the given VARIANT object to the current COleVariant
object.
void Attach(VARIANT& varSrc);
ParámetrosParameters
varSrcvarSrc
Objeto existente VARIANT
que se va a adjuntar al COleVariant
objeto actual.An existing VARIANT
object to be attached to the current COleVariant
object.
ObservacionesRemarks
Esta función establece el VARTYPE de varSrc en VT_EMPTY.This function sets the VARTYPE of varSrc to VT_EMPTY.
Para obtener más información, vea las entradas Variant y VARENUM en el Windows SDK.For more information, see the VARIANT and VARENUM entries in the Windows SDK.
COleVariant:: COleVariantCOleVariant::COleVariant
Construye un objeto COleVariant
.Constructs a COleVariant
object.
COleVariant();
COleVariant(const VARIANT& varSrc);
COleVariant(const COleVariant& varSrc);
COleVariant(LPCVARIANT pSrc);
COleVariant(LPCTSTR lpszSrc);
COleVariant(LPCTSTR lpszSrc, VARTYPE vtSrc);
COleVariant(CString& strSrc);
COleVariant(BYTE nSrc);
COleVariant(short nSrc, VARTYPE vtSrc = VT_I2);
COleVariant(long lSrc,VARTYPE vtSrc = VT_I4);
COleVariant(const COleCurrency& curSrc);
COleVariant(float fltSrc);
COleVariant(double dblSrc);
COleVariant(const COleDateTime& timeSrc);
COleVariant(const CByteArray& arrSrc);
COleVariant(const CLongBinary& lbSrc);
COleVariant(LPCITEMIDLIST pidl);
ParámetrosParameters
varSrcvarSrc
COleVariant
Objeto o existente VARIANT
que se va a copiar en el nuevo COleVariant
objeto.An existing COleVariant
or VARIANT
object to be copied into the new COleVariant
object.
pSrcpSrc
Un puntero a un VARIANT
objeto que se copiará en el nuevo COleVariant
objeto.A pointer to a VARIANT
object that will be copied into the new COleVariant
object.
lpszSrclpszSrc
Una cadena terminada en null que se va a copiar en el nuevo COleVariant
objeto.A null-terminated string to be copied into the new COleVariant
object.
vtSrcvtSrc
Del VARTYPE
nuevo COleVariant
objeto.The VARTYPE
for the new COleVariant
object.
strSrcstrSrc
Objeto CString que se va a copiar en el nuevo COleVariant
objeto.A CString object to be copied into the new COleVariant
object.
nSrc, lSrc un valor numérico que se va a copiar en el nuevo COleVariant
objeto.nSrc, lSrc A numerical value to be copied into the new COleVariant
object.
vtSrcvtSrc
Del VARTYPE
nuevo COleVariant
objeto.The VARTYPE
for the new COleVariant
object.
curSrccurSrc
Objeto COleCurrency que se va a copiar en el nuevo COleVariant
objeto.A COleCurrency object to be copied into the new COleVariant
object.
fltSrc, dblSrcfltSrc, dblSrc
Un valor numérico que se va a copiar en el nuevo objeto COleVariant
.A numerical value to be copied into the new COleVariant
object.
timeSrctimeSrc
Objeto COleDateTime que se va a copiar en el nuevo COleVariant
objeto.A COleDateTime object to be copied into the new COleVariant
object.
arrSrcarrSrc
Objeto CByteArray que se va a copiar en el nuevo COleVariant
objeto.A CByteArray object to be copied into the new COleVariant
object.
lbSrclbSrc
Objeto CLongBinary que se va a copiar en el nuevo COleVariant
objeto.A CLongBinary object to be copied into the new COleVariant
object.
pidlpidl
Puntero a una estructura ITEMIDLIST que se va a copiar en el nuevo COleVariant
objeto.A pointer to a ITEMIDLIST structure to be copied into the new COleVariant
object.
ObservacionesRemarks
Todos estos constructores crean nuevos COleVariant
objetos inicializados en el valor especificado.All these constructors create new COleVariant
objects initialized to the specified value. A continuación se muestra una breve descripción de cada uno de estos constructores.A brief description of each of these constructors follows.
COleVariant () Crea un
COleVariant
objeto vacío VT_EMPTY.COleVariant( ) Creates an emptyCOleVariant
object, VT_EMPTY.COleVariant ( varSrc ) Copia un
VARIANT
objeto o existenteCOleVariant
.COleVariant( varSrc ) Copies an existingVARIANT
orCOleVariant
object. El tipo variant se conserva.The variant type is retained.COleVariant ( pSrc ) Copia un
VARIANT
objeto o existenteCOleVariant
.COleVariant( pSrc ) Copies an existingVARIANT
orCOleVariant
object. El tipo variant se conserva.The variant type is retained.COleVariant ( lpszSrc ) Copia una cadena en el nuevo objeto, VT_BSTR (Unicode).COleVariant( lpszSrc ) Copies a string into the new object, VT_BSTR (UNICODE).
COleVariant ( lpszSrc , vtSrc ) Copia una cadena en el nuevo objeto.COleVariant( lpszSrc , vtSrc ) Copies a string into the new object. El parámetro vtSrc debe ser VT_BSTR (Unicode) o VT_BSTRT (ANSI).The parameter vtSrc must be VT_BSTR (UNICODE) or VT_BSTRT (ANSI).
COleVariant ( strSrc ) Copia una cadena en el nuevo objeto, VT_BSTR (Unicode).COleVariant( strSrc ) Copies a string into the new object, VT_BSTR (UNICODE).
COleVariant ( nSrc ) Copia un entero de 8 bits en el nuevo objeto, VT_UI1.COleVariant( nSrc ) Copies an 8-bit integer into the new object, VT_UI1.
COleVariant ( nSrc , vtSrc ) Copia un entero de 16 bits (o un valor booleano) en el nuevo objeto.COleVariant( nSrc , vtSrc ) Copies a 16-bit integer (or Boolean value) into the new object. El parámetro vtSrc debe ser VT_I2 o VT_BOOL.The parameter vtSrc must be VT_I2 or VT_BOOL.
COleVariant ( lSrc , vtSrc ) Copia un entero de 32 bits (o el valor SCODE) en el nuevo objeto.COleVariant( lSrc , vtSrc ) Copies a 32-bit integer (or SCODE value) into the new object. El parámetro vtSrc debe ser VT_I4, VT_ERROR o VT_BOOL.The parameter vtSrc must be VT_I4, VT_ERROR, or VT_BOOL.
COleVariant ( curSrc ) Copia un
COleCurrency
valor en el nuevo objeto, VT_CY.COleVariant( curSrc ) Copies aCOleCurrency
value into the new object, VT_CY.COleVariant ( fltSrc ) Copia un valor de punto flotante de 32 bits en el nuevo objeto, VT_R4.COleVariant( fltSrc ) Copies a 32-bit floating-point value into the new object, VT_R4.
COleVariant ( dblSrc ) Copia un valor de punto flotante de 64 bits en el nuevo objeto, VT_R8.COleVariant( dblSrc ) Copies a 64-bit floating-point value into the new object, VT_R8.
COleVariant ( timeSrc ) Copia un
COleDateTime
valor en el nuevo objeto, VT_DATE.COleVariant( timeSrc ) Copies aCOleDateTime
value into the new object, VT_DATE.COleVariant ( arrSrc ) Copia un
CByteArray
objeto en el nuevo objeto, VT_EMPTY.COleVariant( arrSrc ) Copies aCByteArray
object into the new object, VT_EMPTY.COleVariant ( lbSrc ) Copia un
CLongBinary
objeto en el nuevo objeto, VT_EMPTY.COleVariant( lbSrc ) Copies aCLongBinary
object into the new object, VT_EMPTY.
Para obtener más información sobre SCODE, vea estructura de los códigos de error com en el Windows SDK.For more information on SCODE, see Structure of COM Error Codes in the Windows SDK.
COleVariant:: ChangeTypeCOleVariant::ChangeType
Convierte el tipo de valor Variant de este COleVariant
objeto.Converts the type of variant value in this COleVariant
object.
void ChangeType(VARTYPE vartype, LPVARIANT pSrc = NULL);
ParámetrosParameters
VarTypevartype
VARTYPE para este COleVariant
objeto.The VARTYPE for this COleVariant
object.
pSrcpSrc
Puntero al objeto Variant que se va a convertir.A pointer to the VARIANT object to be converted. Si este valor es NULL, este COleVariant
objeto se utiliza como el origen de la conversión.If this value is NULL, this COleVariant
object is used as the source for the conversion.
ObservacionesRemarks
Para obtener más información, vea las entradas Variant, VARENUMy VariantChangeType en el Windows SDK.For more information, see the VARIANT, VARENUM, and VariantChangeType entries in the Windows SDK.
COleVariant:: ClearCOleVariant::Clear
Borra la colección VARIANT
.Clears the VARIANT
.
void Clear();
ObservacionesRemarks
Esto establece el VARTYPE de este objeto en VT_EMPTY.This sets the VARTYPE for this object to VT_EMPTY. El COleVariant
destructor llama a esta función.The COleVariant
destructor calls this function.
Para obtener más información, vea las VARIANT
entradas, VARTYPE y VariantClear
en el Windows SDK.For more information, see the VARIANT
, VARTYPE, and VariantClear
entries in the Windows SDK.
COleVariant::D EtachCOleVariant::Detach
Desasocia el objeto Variant subyacente de este COleVariant
objeto.Detaches the underlying VARIANT object from this COleVariant
object.
VARIANT Detach();
ObservacionesRemarks
Esta función establece el VARTYPE de este COleVariant
objeto en VT_EMPTY.This function sets the VARTYPE for this COleVariant
object to VT_EMPTY.
Nota
Después de llamar a Detach
, es responsabilidad del llamador llamar a VariantClear
en la VARIANT
estructura resultante.After calling Detach
, it is the caller's responsibility to call VariantClear
on the resulting VARIANT
structure.
Para obtener más información, vea las entradas Variant, VARENUMy VariantClear en el Windows SDK.For more information, see the VARIANT, VARENUM, and VariantClear entries in the Windows SDK.
COleVariant:: GetByteArrayFromVariantArrayCOleVariant::GetByteArrayFromVariantArray
Recupera una matriz de bytes de una matriz de variantes existente.Retrieves a byte array from an existing variant array
void GetByteArrayFromVariantArray(CByteArray& bytes);
ParámetrosParameters
bytesbytes
Referencia a un objeto CByteArray existente.A reference to an existing CByteArray object.
COleVariant:: Operator LPCVARIANTCOleVariant::operator LPCVARIANT
Este operador de conversión devuelve una VARIANT
estructura cuyo valor se copia de este COleVariant
objeto.This casting operator returns a VARIANT
structure whose value is copied from this COleVariant
object.
operator LPCVARIANT() const;
ObservacionesRemarks
COleVariant:: Operator LPVARIANTCOleVariant::operator LPVARIANT
Llame a este operador de conversión para tener acceso a la VARIANT
estructura subyacente de este COleVariant
objeto.Call this casting operator to access the underlying VARIANT
structure for this COleVariant
object.
operator LPVARIANT();
ObservacionesRemarks
Precaución
Al cambiar el valor de la VARIANT
estructura a la que accede el puntero devuelto por esta función, cambiará el valor de este COleVariant
objeto.Changing the value in the VARIANT
structure accessed by the pointer returned by this function will change the value of this COleVariant
object.
COleVariant:: Operator =COleVariant::operator =
Estos operadores de asignación sobrecargados copian el valor de origen en este COleVariant
objeto.These overloaded assignment operators copy the source value into this COleVariant
object.
const COleVariant& operator=(const VARIANT& varSrc);
const COleVariant& operator=(LPCVARIANT pSrc);
const COleVariant& operator=(const COleVariant& varSrc);
const COleVariant& operator=(const LPCTSTR lpszSrc);
const COleVariant& operator=(const CString& strSrc);
const COleVariant& operator=(BYTE nSrc);
const COleVariant& operator=(short nSrc);
const COleVariant& operator=(long lSrc);
const COleVariant& operator=(const COleCurrency& curSrc);
const COleVariant& operator=(float fltSrc);
const COleVariant& operator=(double dblSrc);
const COleVariant& operator=(const COleDateTime& dateSrc);
const COleVariant& operator=(const CByteArray& arrSrc);
const COleVariant& operator=(const CLongBinary& lbSrc);
ObservacionesRemarks
A continuación se muestra una breve descripción de cada operador:A brief description of each operator follows:
Operator = ( varSrc ) Copia una variante u
COleVariant
objeto existente en este objeto.operator =( varSrc ) Copies an existing VARIANT orCOleVariant
object into this object.Operator = ( pSrc ) Copia el objeto variante al que tiene acceso pSrc en este objeto.operator =( pSrc ) Copies the VARIANT object accessed by pSrc into this object.
Operator = ( lpszSrc ) Copia una cadena terminada en null en este objeto y establece VARTYPE en VT_BSTR.operator =( lpszSrc ) Copies a null-terminated string into this object and sets the VARTYPE to VT_BSTR.
Operator = ( strSrc ) Copia un objeto CString en este objeto y establece VARTYPE en VT_BSTR.operator =( strSrc ) Copies a CString object into this object and sets the VARTYPE to VT_BSTR.
Operator = ( nSrc ) Copia un valor entero de 8 o 16 bits en este objeto.operator =( nSrc ) Copies an 8- or 16-bit integer value into this object. Si nSrc es un valor de 8 bits, el VARTYPE de se establece en VT_UI1.If nSrc is an 8-bit value, the VARTYPE of this is set to VT_UI1. Si nSrc es un valor de 16 bits y el VARTYPE de este es VT_BOOL, se mantiene; de lo contrario, se establece en VT_I2.If nSrc is a 16-bit value and the VARTYPE of this is VT_BOOL, it is kept; otherwise, it is set to VT_I2.
Operator = ( lSrc ) Copia un valor entero de 32 bits en este objeto.operator =( lSrc ) Copies a 32-bit integer value into this object. Si el VARTYPE de este VT_ERROR es, se mantiene; de lo contrario, se establece en VT_I4.If the VARTYPE of this is VT_ERROR, it is kept; otherwise, it is set to VT_I4.
Operator = ( curSrc ) Copia un objeto COleCurrency en este objeto y establece VARTYPE en VT_CY.operator =( curSrc ) Copies a COleCurrency object into this object and sets the VARTYPE to VT_CY.
Operator = ( fltSrc ) Copia un valor de punto flotante de 32 bits en este objeto y establece VARTYPE en VT_R4.operator =( fltSrc ) Copies a 32-bit floating-point value into this object and sets the VARTYPE to VT_R4.
Operator = ( dblSrc ) Copia un valor de punto flotante de 64 bits en este objeto y establece VARTYPE en VT_R8.operator =( dblSrc ) Copies a 64-bit floating-point value into this object and sets the VARTYPE to VT_R8.
Operator = ( dateSrc ) Copia un objeto COleDateTime en este objeto y establece VARTYPE en VT_DATE.operator =( dateSrc ) Copies a COleDateTime object into this object and sets the VARTYPE to VT_DATE.
Operator = ( arrSrc ) Copia un objeto CByteArray en este
COleVariant
objeto.operator =( arrSrc ) Copies a CByteArray object into thisCOleVariant
object.Operator = ( lbSrc ) Copia un objeto CLongBinary en este
COleVariant
objeto.operator =( lbSrc ) Copies a CLongBinary object into thisCOleVariant
object.
Para obtener más información, vea las entradas Variant y VARENUM en el Windows SDK.For more information, see the VARIANT and VARENUM entries in the Windows SDK.
COleVariant:: Operator = =COleVariant::operator ==
Este operador compara dos valores de variante y devuelve un valor distinto de cero si son iguales; de lo contrario, es 0.This operator compares two variant values and returns nonzero if they are equal; otherwise 0.
BOOL operator==(const VARIANT& varSrc) const;
BOOL operator==(LPCVARIANT pSrc) const;
COleVariant:: < < (operador),>>COleVariant::operator <<, >>
Envía un COleVariant
valor a CArchive
o CdumpContext
y escribe un COleVariant
objeto de CArchive
.Outputs a COleVariant
value to CArchive
or CdumpContext
and inputs a COleVariant
object from CArchive
.
friend CDumpContext& AFXAPI operator<<(
CDumpContext& dc,
OleVariant varSrc);
friend CArchive& AFXAPI operator<<(
CArchive& ar,
COleVariant varSrc);
friend CArchive& AFXAPI operator>>(
CArchive& ar,
COleVariant& varSrc);
ObservacionesRemarks
El COleVariant
operador de inserción ( <<) operator supports diagnostic dumping and storing to an archive. The extraction (>> ) permite cargar desde un archivo.The COleVariant
insertion (<<) operator supports diagnostic dumping and storing to an archive. The extraction (>>) operator supports loading from an archive.
COleVariant:: SetStringCOleVariant::SetString
Establece la cadena en un tipo determinado.Sets the string to a particular type.
void SetString(LPCTSTR lpszSrc, VARTYPE vtSrc);
ParámetrosParameters
lpszSrclpszSrc
Una cadena terminada en null que se va a copiar en el nuevo COleVariant
objeto.A null-terminated string to be copied into the new COleVariant
object.
VtSrcVtSrc
VARTYPE del nuevo COleVariant
objeto.The VARTYPE for the new COleVariant
object.
ObservacionesRemarks
El parámetro vtSrc debe ser VT_BSTR (Unicode) o VT_BSTRT (ANSI).The parameter vtSrc must be VT_BSTR (UNICODE) or VT_BSTRT (ANSI). SetString
se utiliza normalmente para establecer cadenas en ANSI, dado que el valor predeterminado para el constructor COleVariant:: COleVariant con un parámetro de cadena o de puntero de cadena y ningún VARTYPE es Unicode.SetString
is typically used to set strings to ANSI, since the default for the COleVariant::COleVariant constructor with a string or string pointer parameter and no VARTYPE is UNICODE.
Un conjunto de registros DAO en una compilación no Unicode espera que las cadenas sean ANSI.A DAO recordset in a non-UNICODE build expects strings to be ANSI. Por lo tanto, para las funciones DAO que usan COleVariant
objetos, si no está creando un conjunto de registros Unicode, debe usar la forma COleVariant:: COleVariant ( lpszSrc , vtSrc ) del constructor con vtSrc establecido en VT_BSTRT (ANSI) o usar SetString
con vtSrc establecido en VT_BSTRT para crear cadenas ANSI.Thus, for DAO functions that use COleVariant
objects, if you are not creating a UNICODE recordset, you must use the COleVariant::COleVariant( lpszSrc , vtSrc ) form of constructor with vtSrc set to VT_BSTRT (ANSI) or use SetString
with vtSrc set to VT_BSTRT to make ANSI strings. Por ejemplo, las CDaoRecordset
funciones CDaoRecordset:: Seek y CDaoRecordset:: SetFieldValue usan COleVariant
objetos como parámetros.For example, the CDaoRecordset
functions CDaoRecordset::Seek and CDaoRecordset::SetFieldValue use COleVariant
objects as parameters. Estos objetos deben ser ANSI si el conjunto de registros DAO no es Unicode.These objects must be ANSI if the DAO recordset is not UNICODE.