Libcroco
Data Structures | Typedefs | Enumerations | Functions
cr-num.h File Reference

The declaration of the CRNum class. More...

#include <glib.h>
#include "cr-utils.h"
#include "cr-parsing-location.h"

Go to the source code of this file.

Data Structures

struct  _CRNum
 An abstraction of a number (num) as defined in the css2 spec. More...
 

Typedefs

typedef struct _CRNum CRNum
 An abstraction of a number (num) as defined in the css2 spec. More...
 

Enumerations

enum  CRNumType {
  NUM_AUTO = 0, NUM_GENERIC, NUM_LENGTH_EM, NUM_LENGTH_EX,
  NUM_LENGTH_PX, NUM_LENGTH_IN, NUM_LENGTH_CM, NUM_LENGTH_MM,
  NUM_LENGTH_PT, NUM_LENGTH_PC, NUM_ANGLE_DEG, NUM_ANGLE_RAD,
  NUM_ANGLE_GRAD, NUM_TIME_MS, NUM_TIME_S, NUM_FREQ_HZ,
  NUM_FREQ_KHZ, NUM_PERCENTAGE, NUM_INHERIT, NUM_UNKNOWN_TYPE,
  NB_NUM_TYPE
}
 The different types of numbers. More...
 

Functions

CRNumcr_num_new (void)
 @CRNum: More...
 
CRNumcr_num_new_with_val (gdouble a_val, enum CRNumType a_type)
 cr_num_new_with_val: @a_val: the numerical value of the number. More...
 
CRNumcr_num_dup (CRNum const *a_this)
 cr_num_dup: @a_this: the instance of CRNum to duplicate. More...
 
guchar * cr_num_to_string (CRNum const *a_this)
 cr_num_to_string: @a_this: the current instance of CRNum. More...
 
enum CRStatus cr_num_copy (CRNum *a_dest, CRNum const *a_src)
 cr_num_copy: @a_src: the instance of CRNum to copy. More...
 
enum CRStatus cr_num_set (CRNum *a_this, gdouble a_val, enum CRNumType a_type)
 cr_num_set: Sets an instance of CRNum. More...
 
gboolean cr_num_is_fixed_length (CRNum const *a_this)
 cr_num_is_fixed_length: @a_this: the current instance of CRNum . More...
 
void cr_num_destroy (CRNum *a_this)
 cr_num_destroy: @a_this: the this pointer of the current instance of CRNum. More...
 

Detailed Description

The declaration of the CRNum class.

Definition in file cr-num.h.

Typedef Documentation

◆ CRNum

typedef struct _CRNum CRNum

An abstraction of a number (num) as defined in the css2 spec.

Definition at line 84 of file cr-num.h.

Enumeration Type Documentation

◆ CRNumType

enum CRNumType

The different types of numbers.

Please, do not modify the declaration order of the enum members, unless you know what you are doing.

Enumerator
NUM_AUTO 
NUM_GENERIC 
NUM_LENGTH_EM 
NUM_LENGTH_EX 
NUM_LENGTH_PX 
NUM_LENGTH_IN 
NUM_LENGTH_CM 
NUM_LENGTH_MM 
NUM_LENGTH_PT 
NUM_LENGTH_PC 
NUM_ANGLE_DEG 
NUM_ANGLE_RAD 
NUM_ANGLE_GRAD 
NUM_TIME_MS 
NUM_TIME_S 
NUM_FREQ_HZ 
NUM_FREQ_KHZ 
NUM_PERCENTAGE 
NUM_INHERIT 
NUM_UNKNOWN_TYPE 
NB_NUM_TYPE 

Definition at line 54 of file cr-num.h.

Function Documentation

◆ cr_num_copy()

enum CRStatus cr_num_copy ( CRNum a_dest,
CRNum const *  a_src 
)

cr_num_copy: @a_src: the instance of CRNum to copy.

Must be non NULL. @a_dest: the destination of the copy. Must be non NULL

Copies an instance of CRNum.

Returns CR_OK upon successful completion, an error code otherwise.

Definition at line 218 of file cr-num.c.

References CR_BAD_PARAM_ERROR, and CR_OK.

Referenced by cr_font_size_copy(), cr_num_dup(), and cr_style_resolve_inherited_properties().

◆ cr_num_destroy()

void cr_num_destroy ( CRNum a_this)

cr_num_destroy: @a_this: the this pointer of the current instance of CRNum.

The destructor of CRNum.

Definition at line 308 of file cr-num.c.

Referenced by cr_font_size_adjust_destroy().

◆ cr_num_dup()

CRNum* cr_num_dup ( CRNum const *  a_this)

cr_num_dup: @a_this: the instance of CRNum to duplicate.

Duplicates an instance of CRNum

Returns the newly created (duplicated) instance of CRNum. Must be freed by cr_num_destroy().

Definition at line 237 of file cr-num.c.

References cr_num_copy(), cr_num_new(), and CR_OK.

◆ cr_num_is_fixed_length()

gboolean cr_num_is_fixed_length ( CRNum const *  a_this)

cr_num_is_fixed_length: @a_this: the current instance of CRNum .

Tests if the current instance of CRNum is a fixed length value or not. Typically a fixed length value is anything from NUM_LENGTH_EM to NUM_LENGTH_PC. See the definition of CRNumType to see what we mean.

Returns TRUE if the instance of CRNum is a fixed length number, FALSE otherwise.

Definition at line 287 of file cr-num.c.

References NUM_LENGTH_EM, NUM_LENGTH_PC, and _CRNum::type.

◆ cr_num_new()

CRNum* cr_num_new ( void  )

@CRNum:

The definition of the CRNum class. cr_num_new:

CRNum.

Returns the newly built instance of CRNum.

Definition at line 44 of file cr-num.c.

References cr_utils_trace_info.

Referenced by cr_num_dup(), and cr_num_new_with_val().

◆ cr_num_new_with_val()

CRNum* cr_num_new_with_val ( gdouble  a_val,
enum CRNumType  a_type 
)

cr_num_new_with_val: @a_val: the numerical value of the number.

@a_type: the type of number.

A constructor of CRNum.

Returns the newly built instance of CRNum or NULL if an error arises.

Definition at line 71 of file cr-num.c.

References cr_num_new(), _CRNum::type, and _CRNum::val.

◆ cr_num_set()

enum CRStatus cr_num_set ( CRNum a_this,
gdouble  a_val,
enum CRNumType  a_type 
)

cr_num_set: Sets an instance of CRNum.

@a_this: the current instance of CRNum to be set. @a_val: the new numerical value to be hold by the current instance of CRNum @a_type: the new type of CRNum.

Returns CR_OK upon succesful completion, an error code otherwise.

Definition at line 264 of file cr-num.c.

References CR_BAD_PARAM_ERROR, CR_OK, _CRNum::type, and _CRNum::val.

Referenced by cr_font_size_set_absolute_font_size(), cr_style_set_props_to_default_values(), and cr_style_set_props_to_initial_values().

◆ cr_num_to_string()

guchar* cr_num_to_string ( CRNum const *  a_this)

cr_num_to_string: @a_this: the current instance of CRNum.

Returns the newly built string representation of the current instance of CRNum. The returned string is NULL terminated. The caller must free the returned string.

Definition at line 95 of file cr-num.c.

References NUM_ANGLE_DEG, NUM_ANGLE_GRAD, NUM_ANGLE_RAD, NUM_AUTO, NUM_FREQ_HZ, NUM_FREQ_KHZ, NUM_GENERIC, NUM_INHERIT, NUM_LENGTH_CM, NUM_LENGTH_EM, NUM_LENGTH_EX, NUM_LENGTH_IN, NUM_LENGTH_MM, NUM_LENGTH_PC, NUM_LENGTH_PT, NUM_LENGTH_PX, NUM_PERCENTAGE, NUM_TIME_MS, NUM_TIME_S, _CRNum::type, and _CRNum::val.

Referenced by cr_font_size_adjust_to_string(), cr_style_num_prop_val_to_string(), cr_term_one_to_string(), and cr_term_to_string().