## AsContentRating AsContentRating — Object representing a content rating |

## Stability Level

Unstable, unless otherwise indicated

## Functions

const gchar * | as_content_rating_value_to_string ()
AsContentRatingValue | as_content_rating_value_from_string ()
guint | as_content_rating_attribute_to_csm_age ()
const gchar ** | as_content_rating_get_all_rating_ids ()
const gchar * | as_content_rating_system_to_string ()
gchar * | as_content_rating_system_format_age ()
AsContentRatingSystem | as_content_rating_system_from_locale ()
gchar ** | as_content_rating_system_get_formatted_ages ()
const guint * | as_content_rating_system_get_csm_ages ()
AsContentRatingValue | as_content_rating_attribute_from_csm_age ()
const gchar * | as_content_rating_attribute_get_description ()
AsContentRating * | as_content_rating_new ()
const gchar * | as_content_rating_get_kind ()
void | as_content_rating_set_kind ()
guint | as_content_rating_get_minimum_age ()
AsContentRatingValue | as_content_rating_get_value ()
void | as_content_rating_set_value ()
const gchar ** | as_content_rating_get_rating_ids ()
void | as_content_rating_add_attribute ()

## Types and Values

#define | AS_TYPE_CONTENT_RATING
struct | AsContentRatingClass
enum | AsContentRatingSystem
enum | AsContentRatingValue
| AsContentRating

## Includes

    #include <appstream.h>

## Description

Content ratings are age-specific guidelines for applications.

See also: AsComponent

## Functions

### as_content_rating_value_to_string ()

    const gchar *
    as_content_rating_value_to_string (AsContentRatingValue value);

Converts the enumerated value to an text representation.

#### Parameters

value | the AsContentRatingValue. |

#### Returns

string version of `value`

Since: 0.11.0

### as_content_rating_value_from_string ()

    AsContentRatingValue
    as_content_rating_value_from_string (const gchar *value);

Converts the text representation to an enumerated value.

#### Parameters

value | the string. |

#### Returns

a AsContentRatingValue or `AS_CONTENT_RATING_VALUE_UNKNOWN` for unknown

Since: 0.11.0

### as_content_rating_attribute_to_csm_age ()

    guint
    as_content_rating_attribute_to_csm_age
                                   (const gchar *id,
                                    AsContentRatingValue value);

Gets the Common Sense Media approved age for a specific rating level.

#### Parameters

id | the subsection ID e.g. `violence-cartoon` |
value | the AsContentRatingValue, e.g. `AS_CONTENT_RATING_VALUE_INTENSE` |

#### Returns

The age in years, or 0 for no details.

Since: 0.12.10

### as_content_rating_get_all_rating_ids ()

    const gchar **
    as_content_rating_get_all_rating_ids (void);

Returns a list of all the valid OARS content rating attribute IDs as could be passed to `as_content_rating_add_attribute()` or `as_content_rating_attribute_to_csm_age()`.

#### Returns

a `NULL`-terminated array of IDs, to be freed with `g_free()` (the element values are owned by libappstream and must not be freed).

[array zero-terminated=1][transfer container]

Since: 0.12.10

### as_content_rating_system_to_string ()

    const gchar *
    as_content_rating_system_to_string (AsContentRatingSystem system);

Get a human-readable string to identify `system` . `NULL` will be returned for `AS_CONTENT_RATING_SYSTEM_UNKNOWN`.

#### Parameters

system | an AsContentRatingSystem |

#### Returns

a human-readable string for `system` , or `NULL` if unknown.

[nullable]

Since: 0.12.12

### as_content_rating_system_format_age ()

    gchar *
    as_content_rating_system_format_age (AsContentRatingSystem system,
                                         guint age);

Format `age` as a human-readable string in the given rating `system` . This is the way to present system-specific strings in a UI.

#### Parameters

system | an AsContentRatingSystem |
age | a CSM age to format |

#### Returns

a newly allocated formatted version of `age` , or `NULL` if the given `system` has no representation for `age` .

[transfer full][nullable]

Since: 0.12.12

### as_content_rating_system_from_locale ()

    AsContentRatingSystem
    as_content_rating_system_from_locale (const gchar *locale);

Determine the most appropriate AsContentRatingSystem for the given `locale` . Content rating systems are selected by territory. If no content rating system seems suitable, `AS_CONTENT_RATING_SYSTEM_IARC` is returned.

#### Parameters

locale | a locale, in the format described in `man 3 setlocale` |

#### Returns

the most relevant AsContentRatingSystem

Since: 0.12.12

### as_content_rating_system_get_formatted_ages ()

    gchar **
    as_content_rating_system_get_formatted_ages
                                   (AsContentRatingSystem system);

Get an array of all the possible return values of `as_content_rating_system_format_age()` for the given `system` . The array is sorted with youngest CSM age first.

#### Parameters

system | an AsContentRatingSystem |

#### Returns

`NULL`-terminated array of human-readable age strings.

[transfer full]

Since: 0.12.12

### as_content_rating_system_get_csm_ages ()

    const guint *
    as_content_rating_system_get_csm_ages (AsContentRatingSystem system,
                                           gsize *length_out);

Get the CSM ages corresponding to the entries returned by `as_content_rating_system_get_formatted_ages()` for this `system` .

#### Parameters

system | an AsContentRatingSystem |
length_out | return location for the length of the returned array. | [out][not nullable]

#### Returns

an array of CSM ages.

[transfer container][array length=length_out]

Since: 0.12.12

### as_content_rating_attribute_from_csm_age ()

    AsContentRatingValue
    as_content_rating_attribute_from_csm_age
                                   (const gchar *id,
                                    guint age);

Gets the highest AsContentRatingValue which is allowed to be seen by the given Common Sense Media `age` for the given subsection `id` .

For example, if the CSM age mappings for `violence-bloodshed` are:

- age ≥ 0 for `AS_CONTENT_RATING_VALUE_NONE`

- age ≥ 9 for `AS_CONTENT_RATING_VALUE_MILD`

- age ≥ 11 for `AS_CONTENT_RATING_VALUE_MODERATE`

- age ≥ 18 for `AS_CONTENT_RATING_VALUE_INTENSE` then calling this function with `violence-bloodshed` and `age` set to 17 would return `AS_CONTENT_RATING_VALUE_MODERATE`. Calling it with age 18 would return `AS_CONTENT_RATING_VALUE_INTENSE`.

#### Parameters

id | the subsection ID e.g. `violence-cartoon` |
age | the CSM age |

#### Returns

the AsContentRatingValue, or `AS_CONTENT_RATING_VALUE_UNKNOWN` if unknown

Since: 0.12.12

### as_content_rating_attribute_get_description ()

    const gchar *
    as_content_rating_attribute_get_description
                                   (const gchar *id,
                                    AsContentRatingValue value);

Get a human-readable description of what content would be expected to require the content rating attribute given by `id` and `value` .

#### Parameters

id | the subsection ID e.g. `violence-cartoon` |
value | the AsContentRatingValue, e.g. `AS_CONTENT_RATING_VALUE_INTENSE` |

#### Returns

a human-readable description of `id` and `value`

Since: 0.12.12

### as_content_rating_new ()

    AsContentRating *
    as_content_rating_new (void);

Creates a new AsContentRating.

#### Returns

a AsContentRating.

[transfer full]

Since: 0.11.0

### as_content_rating_get_kind ()

    const gchar *
    as_content_rating_get_kind (AsContentRating *content_rating);

Gets the content_rating kind.

#### Parameters

content_rating | a AsContentRating instance. |

#### Returns

a string, e.g. "oars-1.0", or NULL

Since: 0.11.0

### as_content_rating_set_kind ()

    void
    as_content_rating_set_kind (AsContentRating *content_rating,
                                const gchar *kind);

Sets the content rating kind.

#### Parameters

content_rating | a AsContentRating instance. |
kind | the rating kind, e.g. "oars-1.0" |

Since: 0.11.0

### as_content_rating_get_minimum_age ()

    guint
    as_content_rating_get_minimum_age (AsContentRating *content_rating);

Gets the lowest Common Sense Media approved age for the content_rating block. NOTE: these numbers are based on the data and descriptions available from https://www.commonsensemedia.org/about-us/our-mission/about-our-ratings and you may disagree with them.

You're free to disagree with these, and of course you should use your own brain to work our if your child is able to cope with the concepts enumerated here. Some 13 year olds may be fine with the concept of mutilation of body parts; others may get nightmares.

#### Parameters

content_rating | a AsContentRating |

#### Returns

The age in years, 0 for no rating, or G_MAXUINT for no details.

Since: 0.11.0

### as_content_rating_get_value ()

    AsContentRatingValue
    as_content_rating_get_value (AsContentRating *content_rating,
                                 const gchar *id);

Gets the value of a content rating key.

#### Parameters

content_rating | a AsContentRating |
id | A ratings ID, e.g. `violence-bloodshed`. |

#### Returns

the AsContentRatingValue, or `AS_CONTENT_RATING_VALUE_UNKNOWN`

Since: 0.11.0

### as_content_rating_set_value ()

    void
    as_content_rating_set_value (AsContentRating *content_rating,
                                 const gchar *id,
                                 AsContentRatingValue value);

Sets the value of a content rating key.

#### Parameters

content_rating | a AsContentRating |
id | A ratings ID, e.g. `violence-bloodshed`. |
value | A AsContentRatingValue, e.g. `AS_CONTENT_RATING_VALUE_INTENSE` |

Since: 0.11.0

### as_content_rating_get_rating_ids ()

    const gchar **
    as_content_rating_get_rating_ids (AsContentRating *content_rating);

Gets the set of ratings IDs which are present in this `content_rating` . An example of a ratings ID is `violence-bloodshed`.

The IDs are returned in lexicographical order.

#### Parameters

content_rating | a AsContentRating |

#### Returns

`NULL`-terminated array of ratings IDs; each ratings ID is owned by the AsContentRating and must not be freed, but the container must be freed with `g_free()`.

[array zero-terminated=1][transfer container]

Since: 0.12.10

### as_content_rating_add_attribute ()

    void
    as_content_rating_add_attribute (AsContentRating *content_rating,
                                     const gchar *id,
                                     AsContentRatingValue value);

Adds an attribute value to the content rating.

#### Parameters

content_rating | a AsContentRating instance. |
id | a content rating ID, e.g. `money-gambling`. |
value | a AsContentRatingValue, e.g. `AS_CONTENT_RATING_VALUE_MODERATE`. |

Since: 0.14.0

## Types and Values

### AS_TYPE_CONTENT_RATING

    #define AS_TYPE_CONTENT_RATING (as_content_rating_get_type ())

### struct AsContentRatingClass

    struct AsContentRatingClass {
    	GObjectClass		parent_class;
    };

### enum AsContentRatingSystem

A content rating system for a particular territory.

#### Members

AS_CONTENT_RATING_SYSTEM_UNKNOWN | Unknown ratings system |
AS_CONTENT_RATING_SYSTEM_INCAA | INCAA |
AS_CONTENT_RATING_SYSTEM_ACB | ACB |
AS_CONTENT_RATING_SYSTEM_DJCTQ | DJCTQ |
AS_CONTENT_RATING_SYSTEM_GSRR | GSRR |
AS_CONTENT_RATING_SYSTEM_PEGI | PEGI |
AS_CONTENT_RATING_SYSTEM_KAVI | KAVI |
AS_CONTENT_RATING_SYSTEM_USK | USK |
AS_CONTENT_RATING_SYSTEM_ESRA | ESRA |
AS_CONTENT_RATING_SYSTEM_CERO | CERO |
AS_CONTENT_RATING_SYSTEM_OFLCNZ | OFLCNZ |
AS_CONTENT_RATING_SYSTEM_RUSSIA | Russia |
AS_CONTENT_RATING_SYSTEM_MDA | MDA |
AS_CONTENT_RATING_SYSTEM_GRAC | GRAC |
AS_CONTENT_RATING_SYSTEM_ESRB | ESRB |
AS_CONTENT_RATING_SYSTEM_IARC | IARC |

Since: 0.12.12

### enum AsContentRatingValue

The specified level of an content_rating rating ID.

#### Members

AS_CONTENT_RATING_VALUE_UNKNOWN | Unknown value |
AS_CONTENT_RATING_VALUE_NONE | None |
AS_CONTENT_RATING_VALUE_MILD | A small amount |
AS_CONTENT_RATING_VALUE_MODERATE | A moderate amount |
AS_CONTENT_RATING_VALUE_INTENSE | An intense amount |

### AsContentRating

    typedef struct _AsContentRating AsContentRating;