mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-07-15 21:40:11 +02:00
Implement date value support (Issue #13)
This commit is contained in:
52
pdfio-dict.c
52
pdfio-dict.c
@ -170,6 +170,7 @@ pdfioDictGetArray(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_ARRAY)
|
||||
return (value->value.array);
|
||||
else
|
||||
@ -188,6 +189,7 @@ pdfioDictGetBinary(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (!length)
|
||||
return (NULL);
|
||||
|
||||
@ -214,6 +216,7 @@ pdfioDictGetBoolean(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_BOOLEAN)
|
||||
return (value->value.boolean);
|
||||
else
|
||||
@ -221,6 +224,24 @@ pdfioDictGetBoolean(pdfio_dict_t *dict, // I - Dictionary
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioDictGetDate()' - Get a date value from a dictionary.
|
||||
//
|
||||
|
||||
time_t // O - Value
|
||||
pdfioDictGetDate(pdfio_dict_t *dict, // I - Dictionary
|
||||
const char *key) // I - Key
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_DATE)
|
||||
return (value->value.date);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioDictGetDict()' - Get a key dictionary value from a dictionary.
|
||||
//
|
||||
@ -231,6 +252,7 @@ pdfioDictGetDict(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_DICT)
|
||||
return (value->value.dict);
|
||||
else
|
||||
@ -248,6 +270,7 @@ pdfioDictGetName(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_NAME)
|
||||
return (value->value.name);
|
||||
else
|
||||
@ -265,6 +288,7 @@ pdfioDictGetNumber(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_NUMBER)
|
||||
return (value->value.number);
|
||||
else
|
||||
@ -282,6 +306,7 @@ pdfioDictGetObj(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_INDIRECT)
|
||||
return (pdfioFileFindObj(dict->pdf, value->value.indirect.number));
|
||||
else
|
||||
@ -300,6 +325,7 @@ pdfioDictGetRect(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_ARRAY && pdfioArrayGetSize(value->value.array) == 4)
|
||||
{
|
||||
rect->x1 = pdfioArrayGetNumber(value->value.array, 0);
|
||||
@ -326,6 +352,7 @@ pdfioDictGetString(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
if (value && value->type == PDFIO_VALTYPE_STRING)
|
||||
return (value->value.string);
|
||||
else
|
||||
@ -343,6 +370,7 @@ pdfioDictGetType(pdfio_dict_t *dict, // I - Dictionary
|
||||
{
|
||||
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
|
||||
|
||||
|
||||
return (value ? value->type : PDFIO_VALTYPE_NONE);
|
||||
}
|
||||
|
||||
@ -524,6 +552,30 @@ pdfioDictSetBoolean(pdfio_dict_t *dict, // I - Dictionary
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioDictSetDate()' - Set a date value in a dictionary.
|
||||
//
|
||||
|
||||
bool // O - `true` on success, `false` on failure
|
||||
pdfioDictSetDate(pdfio_dict_t *dict, // I - Dictionary
|
||||
const char *key, // I - Key
|
||||
time_t value) // I - Value
|
||||
{
|
||||
_pdfio_value_t temp; // New value
|
||||
|
||||
|
||||
// Range check input...
|
||||
if (!dict || !key)
|
||||
return (false);
|
||||
|
||||
// Set the key/value pair...
|
||||
temp.type = PDFIO_VALTYPE_DATE;
|
||||
temp.value.date = value;
|
||||
|
||||
return (_pdfioDictSetValue(dict, key, &temp));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioDictSetDict()' - Set a key dictionary in a dictionary.
|
||||
//
|
||||
|
Reference in New Issue
Block a user