예제 #1
0
	string Coll::getAttribute( const string &attrname ) const
	{
		const char *val;
		if( !xmmsv_coll_attribute_get_string( coll_, attrname.c_str(), &val ) ) {
			throw no_such_key_error( "No such attribute: " + attrname );
		}

		return string( val );
	}
예제 #2
0
static void
playlist_coll_attribute_get_position (xmmsv_t *coll, gint *pos)
{
	const gchar *str = NULL;
	if (xmmsv_coll_attribute_get_string (coll, "position", &str)) {
		*pos = strtol (str, NULL, 10);
	} else {
		*pos = -1;
	}
}
예제 #3
0
/* Augment the collection with new attributes needed for coll2 */
static xmmsv_t *
augment_coll (xmmsv_t *coll)
{
    xmmsv_t *ret = coll;
    const char *key;

    switch (xmmsv_coll_get_type (coll)) {
    case XMMS_COLLECTION_TYPE_HAS:
    case XMMS_COLLECTION_TYPE_MATCH:
    case XMMS_COLLECTION_TYPE_TOKEN:
    case XMMS_COLLECTION_TYPE_EQUALS:
    case XMMS_COLLECTION_TYPE_NOTEQUAL:
    case XMMS_COLLECTION_TYPE_SMALLER:
    case XMMS_COLLECTION_TYPE_SMALLEREQ:
    case XMMS_COLLECTION_TYPE_GREATER:
    case XMMS_COLLECTION_TYPE_GREATEREQ:
        if (xmmsv_coll_attribute_get_string (coll, "field", &key)
                && strcmp (key, "id") == 0) {
            xmmsv_coll_attribute_set_string (coll, "type", "id");
        } else {
            xmmsv_coll_attribute_set_string (coll, "type", "value");
        }
        break;

    case XMMS_COLLECTION_TYPE_REFERENCE:
        if (xmmsv_coll_attribute_get_string (coll, "reference", &key)
                && strcmp (key, "All Media") == 0) {
            ret = xmmsv_new_coll (XMMS_COLLECTION_TYPE_UNIVERSE);
            xmmsv_unref (coll);
        }
        break;

    default:
        break;
    }

    return ret;
}
예제 #4
0
static VALUE
c_attrs_has_key (VALUE self, VALUE key)
{
	RbCollection *coll = NULL;
	VALUE tmp;
	int s;

	StringValue (key);

	tmp = rb_iv_get (self, "collection");
	Data_Get_Struct (tmp, RbCollection, coll);

	s = xmmsv_coll_attribute_get_string (coll->real, StringValuePtr (key), NULL);

	return s ? Qtrue : Qfalse;
}
예제 #5
0
static VALUE
c_attrs_aref (VALUE self, VALUE key)
{
	RbCollection *coll = NULL;
	VALUE tmp;
	int s;
	const char *value;

	StringValue (key);

	tmp = rb_iv_get (self, "collection");
	Data_Get_Struct (tmp, RbCollection, coll);

	s = xmmsv_coll_attribute_get_string (coll->real, StringValuePtr (key), &value);
	if (!s)
		return Qnil;

	return rb_str_new2 (value);
}
예제 #6
0
	Coll::Coll* extract_collection( xmmsv_t* coll )
	{
		Coll::Coll* temp = 0;
		switch( xmmsv_coll_get_type( coll ) ) {

			case XMMS_COLLECTION_TYPE_REFERENCE: {
				temp = new Coll::Reference( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_UNION: {
				temp = new Coll::Union( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_INTERSECTION: {
				temp = new Coll::Intersection( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_COMPLEMENT: {
				temp = new Coll::Complement( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_EQUALS: {
				temp = new Coll::Equals( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_NOTEQUAL: {
				temp = new Coll::NotEquals( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_SMALLER: {
				temp = new Coll::Smaller( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_SMALLEREQ: {
				temp = new Coll::SmallerEqual( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_GREATER: {
				temp = new Coll::Greater( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_GREATEREQ: {
				temp = new Coll::GreaterEqual( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_HAS: {
				temp = new Coll::Has( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_TOKEN: {
				temp = new Coll::Token( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_MATCH: {
				temp = new Coll::Match( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_ORDER: {
				temp = new Coll::Order( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_LIMIT: {
				temp = new Coll::Limit( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_MEDIASET: {
				temp = new Coll::Mediaset( coll );
				break;
			}
			case XMMS_COLLECTION_TYPE_IDLIST: {
				const char *type = NULL;

				if (!xmmsv_coll_attribute_get_string (coll, "type", &type)) {
					temp = new Coll::Idlist( coll );
				} else if (!strcmp(type, "queue")) {
					temp = new Coll::Queue( coll );
				} else if (!strcmp(type, "partyshuffle")) {
					temp = new Coll::PartyShuffle( coll );
				} else {
					temp = new Coll::Idlist( coll );
				}
				break;
			}
		}

		return temp;
	}
예제 #7
0
/**
 * Retrieve a string attribute from the given collection.
 *
 * @param coll The collection to retrieve the attribute from.
 * @param key  The name of the attribute.
 * @param value The value of the attribute if found (owned by the collection).
 * @return 1 if the attribute was found, 0 otherwise
 */
int
xmmsv_coll_attribute_get (xmmsv_t *coll, const char *key, const char **value)
{
	return xmmsv_coll_attribute_get_string (coll, key, value);
}