⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rvmegacoobjects.c

📁 h.248协议源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	}
	{returns: A pointer to the destination object, or NULL if the copy failed.}
}
$*/
RvMegacoPackageItem *rvMegacoPackageItemCopy(RvMegacoPackageItem *d, const RvMegacoPackageItem *s)
{
	rvStringCopy(&d->package, &s->package);
	rvStringCopy(&d->item, &s->item);
	return d;
}


/*$
{function:
	{name: rvMegacoPackageItemEqual}
	{class: RvMegacoPackageItem}
	{include: rvmegacoobjects.h}
	{description:
		{p: Compares two package item objects for equality.}
	}
	{proto: RvBool rvMegacoPackageItemEqual(const RvMegacoPackageItem *a, const RvMegacoPackageItem *b);}
	{params:
		{param: {n:a} {d:The first package item object.}}
		{param: {n:b} {d:The second package item object.}}
	}
	{returns: rvTrue if the objects are equal, rvFalse if not.}
}
$*/
RvBool rvMegacoPackageItemEqual(const RvMegacoPackageItem *a, const RvMegacoPackageItem *b)
{
	return rvStringEqualIgnoreCase(&a->item, &b->item) &&
		rvStringEqualIgnoreCase(&a->package, &b->package);
}


static RvBool rvMegacoPackageItemLess(const RvMegacoPackageItem *a, const RvMegacoPackageItem *b)
{
	return rvStringEqualIgnoreCase(&a->package, &b->package) ?
		rvStringLessIgnoreCase(&a->item, &b->item) :
		rvStringLessIgnoreCase(&a->package, &b->package);
}


/*$
{function:
	{name: rvMegacoPackageItemGetPackage}
	{class: RvMegacoPackageItem}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the package name of the package item object.}
	}
	{proto: const char *rvMegacoPackageItemGetPackage(const RvMegacoPackageItem *x);}
	{params:
		{param: {n:x} {d:The package item object.}}
	}
	{returns: The package name.}
}
$*/
const char *rvMegacoPackageItemGetPackage(const RvMegacoPackageItem *x)
{
	return rvStringGetData(&x->package);
}


/*$
{function:
	{name: rvMegacoPackageItemGetItem}
	{class: RvMegacoPackageItem}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the name of the package item object.}
	}
	{proto: const char *rvMegacoPackageItemGetItem(const RvMegacoPackageItem *x);}
	{params:
		{param: {n:x} {d:The package item object.}}
	}
	{returns: The name of the item.}
}
$*/
const char *rvMegacoPackageItemGetItem(const RvMegacoPackageItem *x)
{
	return rvStringGetData(&x->item);
}


/*$
{function:
	{name: rvMegacoParameterValueConstruct}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstruct(RvMegacoParameterValue *x, const char *val);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:val} {d:The parameter value.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
	{notes: 
		{note: For under-specified and over-specified parameters use one of the special RvMegacoParameterValue constructors instead.}
	}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstruct(RvMegacoParameterValue *x, const char *val)
{
	return rvMegacoParameterValueConstructA(x, val, &rvDefaultAlloc);
}


/*$
{function:
	{name: rvMegacoParameterValueConstructA}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructA(RvMegacoParameterValue *x, const char *val, RvAlloc *alloc);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:val} {d:The parameter value.}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
	{notes: 
		{note: For under-specified and over-specified parameters use one of the special RvMegacoParameterValue constructors instead.}
	}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructA(RvMegacoParameterValue *x, const char *val, RvAlloc *alloc)
{
	x->type = RV_RELATION_EQUAL;
	rvStringListConstructA(&x->values, alloc);
	rvStringListAdd(&x->values, val);
	return x;
}


/*$
{function:
	{name: rvMegacoParameterValueConstructRange}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object that indicates a range of possible values for a parameter.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructRange(RvMegacoParameterValue *x, const char *lo, const char *hi);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:lo} {d:The minimum value of the parameter.}}
		{param: {n:hi} {d:The maximum value of the parameter.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructRange(RvMegacoParameterValue *x, const char *lo, const char *hi)
{
	return rvMegacoParameterValueConstructRangeA(x, lo, hi, &rvDefaultAlloc);
}


/*$
{function:
	{name: rvMegacoParameterValueConstructRangeA}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructRangeA(RvMegacoParameterValue *x, const char *lo, const char *hi, RvAlloc *alloc);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:lo} {d:The minimum value of the parameter.}}
		{param: {n:hi} {d:The maximum value of the parameter.}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructRangeA(RvMegacoParameterValue *x, const char *lo, const char *hi, RvAlloc *alloc)
{
	x->type = RV_RELATION_RANGE;
	rvStringListConstructA(&x->values, alloc);
	rvStringListAdd(&x->values, lo);
	rvStringListAdd(&x->values, hi);
	return x;
}


/*$
{function:
	{name: rvMegacoParameterValueConstructList}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object that represents a list of possible values.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructList(RvMegacoParameterValue *x, RvRelation type);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:type} {d:The type of list, either "AND" or "OR".}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructList(RvMegacoParameterValue *x, RvRelation type)
{
	return rvMegacoParameterValueConstructListA(x, type, &rvDefaultAlloc);
}


/*$
{function:
	{name: rvMegacoParameterValueConstructListA}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructListA(RvMegacoParameterValue *x, RvRelation type, RvAlloc *alloc);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:type} {d:The type of list, either "AND" or "OR".}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructListA(RvMegacoParameterValue *x, RvRelation type, RvAlloc *alloc)
{
	assert(type == RV_RELATION_AND || type == RV_RELATION_OR);
	x->type = type;
	rvStringListConstructA(&x->values, alloc);
	return x;
}


/*$
{function:
	{name: rvMegacoParameterValueConstructSpecial}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object with a special relation.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructSpecial(RvMegacoParameterValue *x, const char *val, RvRelation type);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:val} {d:The value.}}
		{param: {n:type} {d:The relation.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructSpecial(RvMegacoParameterValue *x, const char *val, RvRelation type)
{
	return rvMegacoParameterValueConstructSpecialA(x, val, type, &rvDefaultAlloc);
}


/*$
{function:
	{name: rvMegacoParameterValueConstructSpecialA}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a parameter value object with a special relation.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructSpecialA(RvMegacoParameterValue *x, const char *val, RvRelation type, RvAlloc *alloc);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:val} {d:The value.}}
		{param: {n:type} {d:The relation.}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructSpecialA(RvMegacoParameterValue *x, const char *val, RvRelation type, RvAlloc *alloc)
{
	assert(type != RV_RELATION_AND && type != RV_RELATION_OR && type != RV_RELATION_RANGE);
	x->type = type;
	rvStringListConstructA(&x->values, alloc);
	rvStringListAdd(&x->values, val);
	return x;
}


/*$
{function:
	{name: rvMegacoParameterValueConstructCopy}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a copy of a parameter value object.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueConstructCopy(RvMegacoParameterValue *d, const RvMegacoParameterValue *s, RvAlloc *alloc);}
	{params:
		{param: {n:d} {d:The destination parameter value object.}}
		{param: {n:s} {d:The parameter value object to copy.}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueConstructCopy(RvMegacoParameterValue *d, const RvMegacoParameterValue *s, RvAlloc *alloc)
{
	d->type = s->type;
	rvStringListConstructCopy(&d->values, &s->values, alloc);
	return d;
}


/*$
{function:
	{name: rvMegacoParameterValueDestruct}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Destroys a parameter value object.}
	}
	{proto: void rvMegacoParameterValueDestruct(RvMegacoParameterValue *x);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
	}
}
$*/
void rvMegacoParameterValueDestruct(RvMegacoParameterValue *x)
{
	rvStringListDestruct(&x->values);
}


/*$
{function:
	{name: rvMegacoParameterValueCopy}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Copies the value of one parameter value object to another.}
	}
	{proto: RvMegacoParameterValue *rvMegacoParameterValueCopy(RvMegacoParameterValue *d, const RvMegacoParameterValue *s);}
	{params:
		{param: {n:d} {d:The destination parameter value object.}}
		{param: {n:s} {d:The parameter value object to copy.}}
	}
	{returns: A pointer to the destination object, or NULL if the copy failed.}
}
$*/
RvMegacoParameterValue *rvMegacoParameterValueCopy(RvMegacoParameterValue *d, const RvMegacoParameterValue *s)
{
	d->type = s->type;
	rvStringListCopy(&d->values, &s->values);
	return d;
}


/*$
{function:
	{name: rvMegacoParameterValueAddToList}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Add a value to a list of possible values. }
	}
	{proto: void rvMegacoParameterValueAddToList(RvMegacoParameterValue *x, const char *val);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
		{param: {n:val} {d:The value.}}
	}
}
$*/
void rvMegacoParameterValueAddToList(RvMegacoParameterValue *x, const char *val)
{
	assert(x->type == RV_RELATION_AND || x->type == RV_RELATION_OR);
	rvStringListAdd(&x->values, val);
}


void rvMegacoParameterValueAddToListUnique(RvMegacoParameterValue *x, const char *val)
{
	size_t i;
	assert(x->type == RV_RELATION_AND || x->type == RV_RELATION_OR);
	for(i=0; i<rvStringListGetSize(&x->values); ++i)
	{
		if(rvStrIcmp(rvStringListGetElem(&x->values, i), val) == 0)
			return;
	}
	rvStringListAdd(&x->values, val);
}


void rvMegacoParameterValueAnd(RvMegacoParameterValue *x, const char *val)
{
	assert(x->type == RV_RELATION_EQUAL || x->type == RV_RELATION_AND);
	x->type = RV_RELATION_AND;
	rvMegacoParameterValueAddToListUnique(x, val);
}


void rvMegacoParameterValueOr(RvMegacoParameterValue *x, const char *val)
{
	assert(x->type == RV_RELATION_EQUAL || x->type == RV_RELATION_OR);
	x->type = RV_RELATION_OR;
	rvMegacoParameterValueAddToListUnique(x, val);
}


/*$
{function:
	{name: rvMegacoParameterValueGetType}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the type of the parameter value object.}
	}
	{proto: RvRelation rvMegacoParameterValueGetType(const RvMegacoParameterValue *x);}
	{params:
		{param: {n:x} {d:The parameter value object.}}
	}
	{returns: The type.}
}
$*/
RvRelation rvMegacoParameterValueGetType(const RvMegacoParameterValue *x)
{
	return x->type;
}


/*$
{function:
	{name: rvMegacoParameterValueGetValue}
	{class: RvMegacoParameterValue}
	{include: rvmegacoobjects.h}
	{description:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -