Pajdeg  0.2.2
Pajdeg
pd_container.h
1 //
20 //#ifndef INCLUDED_PD_CONTAINER_H
21 //#define INCLUDED_PD_CONTAINER_H
22 //
23 //#include "pd_stack.h"
24 //#include "PDReference.h"
25 //#include "pd_dict.h"
26 //#include "pd_array.h"
27 //
29 // * Determine the type of the given stack.
30 // *
31 // * This is a helper function for pd_dict and pd_array.
32 // *
33 // * @param stack PDF implementation compliant stack
34 // *
35 // * @return PDObjectType enum value
36 // */
37 //static inline PDObjectType pd_container_determine_type(pd_stack stack)
38 //{
39 // PDObjectType type = PDObjectTypeNull;
40 // if (stack) {
41 // if (stack->type == PD_STACK_ID) {
42 // PDID id = stack->info;
43 // if (PDIdentifies(id, PD_DICT)) {
44 // type = PDObjectTypeDictionary;
45 // }
46 // else if (PDIdentifies(id, PD_ARRAY)) {
47 // type = PDObjectTypeArray;
48 // }
49 // else if (PDIdentifies(id, PD_NAME)) {
50 // type = PDObjectTypeName;
51 // }
52 // else if (PDIdentifies(id, PD_REF)) {
53 // type = PDObjectTypeReference;
54 // }
55 // else if (PDIdentifies(id, PD_HEXSTR)) {
56 // type = PDObjectTypeString;
57 // }
58 // else {
59 // PDNotice("unknown stack identity symbol encountered");
60 // type = PDObjectTypeUnknown;
61 // }
62 // } else if (stack->type == PD_STACK_STRING) {
63 // type = PDObjectTypeString;
64 // } else {
65 // PDNotice("unparseable stack type %d encountered", stack->type);
66 // }
67 // }
68 //
69 // return type;
70 //}
71 //
73 // * Spawn the appropriate object from the given stack.
74 // *
75 // * @see pd_dict, pd_array
76 // *
77 // * @param stack PDF implementation compliant stack
78 // *
79 // * @return Appropriate object
80 // */
81 //static inline void *pd_container_spawn(pd_stack stack)
82 //{
83 // if (stack) {
84 // if (stack->type == PD_STACK_ID) {
85 // PDID id = stack->info;
86 // if (PDIdentifies(id, PD_DICT)) {
87 // return pd_dict_from_pdf_dict_stack(stack);
88 // }
89 // if (PDIdentifies(id, PD_ARRAY)) {
90 // return pd_array_from_pdf_array_stack(stack);
91 // }
92 // if (PDIdentifies(id, PD_NAME)) {
93 // return strdup(stack->prev->info);
94 // }
95 // if (PDIdentifies(id, PD_REF)) {
96 // return PDReferenceCreateFromStackDictEntry(stack);
97 // }
98 // if (PDIdentifies(id, PD_HEXSTR)) {
99 // char *buf = malloc(3 + strlen(stack->prev->info));
100 // sprintf(buf, "<%s>", stack->prev->info);
101 // return buf; // strdup(stack->prev->info);
102 // }
103 // return NULL;
104 // }
105 // if (stack->prev) {
106 // // it's a short hand array
107 // return pd_array_from_stack(stack);
108 // }
109 // if (stack->type == PD_STACK_STRING) {
110 // return strdup(stack->info);
111 // }
112 // }
113 // return NULL;
114 //}
115 //
116 //#endif