TemplateSource.h File Reference

Templates for source files of objects. More...

`#include "config.h"`
`#include <stdlib.h>`
`#include <string.h>`
`#include "TemplateUndef.h"`
Include dependency graph for TemplateSource.h:

Go to the source code of this file.

## Data Structures

struct | SCLASS

## Macros

#define | TEMPLATE_DEFINITION_INT(MEMBER, TYPE) TYPE m_##MEMBER;
#define | TEMPLATE_DEFINITION_BUFFER(MEMBER, TYPE) TYPE m_##MEMBER;
#define | TEMPLATE_DEFINITION_LIST(MEMBER) struct list_head m_##MEMBER;
#define | TEMPLATE_DEFINITION_OBJECT(MEMBER, TYPE) TYPE *m_##MEMBER;
#define | TEMPLATE_DEFINITION_STRING(MEMBER) UpnpString *m_##MEMBER;
#define | TEMPLATE_DEFINITION_DOMSTRING(MEMBER) DOMString m_##MEMBER;
#define | TEMPLATE_CONSTRUCTOR_INT(MEMBER, TYPE) /* p->m_##MEMBER = 0; */
#define | TEMPLATE_CONSTRUCTOR_BUFFER(MEMBER, TYPE) /* memset(&p->m_##MEMBER, 0, sizeof (TYPE)); */
#define | TEMPLATE_CONSTRUCTOR_LIST(MEMBER, TYPE) INIT_LIST_HEAD(&p->m_##MEMBER);
#define | TEMPLATE_CONSTRUCTOR_OBJECT(MEMBER, TYPE) p->m_##MEMBER = TYPE##_new();
#define | TEMPLATE_CONSTRUCTOR_STRING(MEMBER) p->m_##MEMBER = UpnpString_new();
#define | TEMPLATE_CONSTRUCTOR_DOMSTRING(MEMBER) p->m_##MEMBER = NULL;
#define | TEMPLATE_DESTRUCTOR_INT(MEMBER, TYPE) p->m_##MEMBER = 0;
#define | TEMPLATE_DESTRUCTOR_BUFFER(MEMBER, TYPE) memset(&p->m_##MEMBER, 0, sizeof (TYPE));
#define | TEMPLATE_DESTRUCTOR_LIST(MEMBER) list_del(&p->m_##MEMBER);
#define | TEMPLATE_DESTRUCTOR_OBJECT(MEMBER, TYPE) TYPE##_delete(p->m_##MEMBER); p->m_##MEMBER = NULL;
#define | TEMPLATE_DESTRUCTOR_STRING(MEMBER) UpnpString_delete(p->m_##MEMBER); p->m_##MEMBER = NULL;
#define | TEMPLATE_DESTRUCTOR_DOMSTRING(MEMBER) ixmlFreeDOMString(p->m_##MEMBER); p->m_##MEMBER = NULL;
#define | TEMPLATE_ASSIGNMENT(CLASS, MEMBER) ok = ok && CLASS##_set_##MEMBER(p, CLASS##_get_##MEMBER(q));
#define | TEMPLATE_METHODS_INT(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_INT_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_INT_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_BUFFER_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_BUFFER_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_LIST(CLASS, MEMBER) TEMPLATE_METHODS_LIST_AUX(CLASS, MEMBER)
#define | TEMPLATE_METHODS_LIST_AUX(CLASS, MEMBER)
#define | TEMPLATE_METHODS_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_OBJECT_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_OBJECT_AUX(CLASS, MEMBER, TYPE)
#define | TEMPLATE_METHODS_STRING(CLASS, MEMBER) TEMPLATE_METHODS_STRING_AUX(CLASS, MEMBER)
#define | TEMPLATE_METHODS_STRING_AUX(CLASS, MEMBER)
#define | TEMPLATE_METHODS_DOMSTRING(CLASS, MEMBER) TEMPLATE_METHODS_DOMSTRING_AUX(CLASS, MEMBER)
#define | TEMPLATE_METHODS_DOMSTRING_AUX(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE) TEMPLATE_DEFINITION_INT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_DEFINITION_BUFFER(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER) TEMPLATE_DEFINITION_LIST(MEMBER)
#define | EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_DEFINITION_OBJECT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER) TEMPLATE_DEFINITION_STRING(MEMBER)
#define | EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER) TEMPLATE_DEFINITION_DOMSTRING(MEMBER)
#define | TEMPLATE_DECLARATION_STRUCT(CLASS) TEMPLATE_DECLARATION_STRUCT_AUX(CLASS)
#define | TEMPLATE_DECLARATION_STRUCT_AUX(CLASS)
#define | EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE) TEMPLATE_CONSTRUCTOR_INT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_CONSTRUCTOR_BUFFER(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER) TEMPLATE_CONSTRUCTOR_LIST(MEMBER, MEMBER)
#define | EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_CONSTRUCTOR_OBJECT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER) TEMPLATE_CONSTRUCTOR_STRING(MEMBER)
#define | EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER) TEMPLATE_CONSTRUCTOR_DOMSTRING(MEMBER)
#define | TEMPLATE_DEFINITION_CONSTRUCTOR(CLASS) TEMPLATE_DEFINITION_CONSTRUCTOR_AUX(CLASS)
#define | TEMPLATE_DEFINITION_CONSTRUCTOR_AUX(CLASS)
#define | EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE) TEMPLATE_DESTRUCTOR_INT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_DESTRUCTOR_BUFFER(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER) TEMPLATE_DESTRUCTOR_LIST(MEMBER)
#define | EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_DESTRUCTOR_OBJECT(MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER) TEMPLATE_DESTRUCTOR_STRING(MEMBER)
#define | EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER) TEMPLATE_DESTRUCTOR_DOMSTRING(MEMBER)
#define | TEMPLATE_DEFINITION_DESTRUCTOR(CLASS) TEMPLATE_DEFINITION_DESTRUCTOR_AUX(CLASS)
#define | TEMPLATE_DEFINITION_DESTRUCTOR_AUX(CLASS)
#define | TEMPLATE_DEFINITION_COPY_CONSTRUCTOR(CLASS) TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX(CLASS)
#define | TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX(CLASS)
#define | EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE) TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER) /* Do not assing. */
#define | EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER) TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER) TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define | TEMPLATE_DEFINITION_ASSIGNMENT(CLASS) TEMPLATE_DEFINITION_ASSIGNMENT_AUX(CLASS)
#define | TEMPLATE_DEFINITION_ASSIGNMENT_AUX(CLASS)
#define | EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_INT(CLASS, MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_BUFFER(CLASS, MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER) TEMPLATE_METHODS_LIST(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE) TEMPLATE_METHODS_OBJECT(CLASS, MEMBER, TYPE)
#define | EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER) TEMPLATE_METHODS_STRING(CLASS, MEMBER)
#define | EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER) TEMPLATE_METHODS_DOMSTRING(CLASS, MEMBER)

## Functions

CLASS * | CLASS_new ()
void | CLASS_delete (CLASS *q)
CLASS * | CLASS_dup (const CLASS *q)
int | CLASS_assign (CLASS *p, const CLASS *q)

## Detailed Description

Templates for source files of objects.

Usage:

- In the include file Token.h: #include "Token_def.h" #include "TemplateInclude.h"
- In the source file Token.c: #include "Token.h" #include "TemplateSource.h"

Author
  Marcelo Roberto Jimenez

## Macro Definition Documentation

## TEMPLATE_DECLARATION_STRUCT_AUX

#define TEMPLATE_DECLARATION_STRUCT_AUX | ( |  | CLASS | ) |

Value:
struct S##CLASS { \
EXPAND_CLASS_MEMBERS(CLASS) \
};
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_DEFINITION_ASSIGNMENT_AUX

#define TEMPLATE_DEFINITION_ASSIGNMENT_AUX | ( |  | CLASS | ) |

Value:
int CLASS##_assign(CLASS *p, const CLASS *q) \
{ \
int ok = 1; \
if (p != q) { \
EXPAND_CLASS_MEMBERS(CLASS) \
} \
return ok; \
}
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_DEFINITION_CONSTRUCTOR_AUX

#define TEMPLATE_DEFINITION_CONSTRUCTOR_AUX | ( |  | CLASS | ) |

Value:
CLASS *CLASS##_new() \
{ \
struct S##CLASS *p = calloc(1, sizeof (struct S##CLASS)); \
\
if (!p) return NULL; \
\
EXPAND_CLASS_MEMBERS(CLASS) \
\
return (CLASS *)p; \
}
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX

#define TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX | ( |  | CLASS | ) |

Value:
CLASS *CLASS##_dup(const CLASS *q) \
{ \
CLASS *p = CLASS##_new(); \
\
if (!p) return NULL; \
\
CLASS##_assign(p, q); \
\
return p; \
}
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_DEFINITION_DESTRUCTOR_AUX

#define TEMPLATE_DEFINITION_DESTRUCTOR_AUX | ( |  | CLASS | ) |

Value:
void CLASS##_delete(CLASS *q) \
{ \
struct S##CLASS *p = (struct S##CLASS *)q; \
\
if (!p) return; \
\
EXPAND_CLASS_MEMBERS(CLASS) \
\
free(p); \
}
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_METHODS_BUFFER_AUX

#define TEMPLATE_METHODS_BUFFER_AUX | ( |  | CLASS,
|  |  | MEMBER,
|  |  | TYPE
| ) |  |

Value:
const TYPE *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
return (TYPE *)&((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const TYPE *buf) \
{ \
((struct S##CLASS *)p)->m_##MEMBER = *(TYPE *)buf; \
return 1; \
} \
\
void CLASS##_clear_##MEMBER(CLASS *p) \
{ \
memset(&((struct S##CLASS *)p)->m_##MEMBER, 0, sizeof(TYPE)); \
} \
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_METHODS_DOMSTRING_AUX

#define TEMPLATE_METHODS_DOMSTRING_AUX | ( |  | CLASS,
|  |  | MEMBER
| ) |  |

Value:
const DOMString CLASS##_get_##MEMBER(const CLASS *p) \
{ \
return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const DOMString s) \
{ \
DOMString q = ixmlCloneDOMString(s); \
if (!q) return 0; \
ixmlFreeDOMString(((struct S##CLASS *)p)->m_##MEMBER); \
((struct S##CLASS *)p)->m_##MEMBER = q; \
return 1; \
} \
\
const char *CLASS##_get_##MEMBER##_cstr(const CLASS *p) \
{ \
return (const char *)CLASS##_get_##MEMBER(p); \
} \
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138
ixmlCloneDOMString
EXPORT_SPEC char * ixmlCloneDOMString(const char *src)
Clones an existing DOMString.
DOMString
#define DOMString
The type of DOM strings.
Definition: ixml.h:59

## TEMPLATE_METHODS_INT_AUX

#define TEMPLATE_METHODS_INT_AUX | ( |  | CLASS,
|  |  | MEMBER,
|  |  | TYPE
| ) |  |

Value:
TYPE CLASS##_get_##MEMBER(const CLASS *p) \
{ \
return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, TYPE n) \
{ \
((struct S##CLASS *)p)->m_##MEMBER = n; \
return 1; \
} \
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## TEMPLATE_METHODS_LIST_AUX

#define TEMPLATE_METHODS_LIST_AUX | ( |  | CLASS,
|  |  | MEMBER
| ) |  |

Value:
const struct list_head *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
return (struct list_head *)&((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
void CLASS##_add_to_list_##MEMBER(CLASS *p, struct list_head *head) \
{ \
list_add(&((struct S##CLASS *)p)->m_##MEMBER, head); \
} \
\
void CLASS##_remove_from_list_##MEMBER(CLASS *p) \
{ \
list_del_init(&((struct S##CLASS *)p)->m_##MEMBER); \
} \
\
void CLASS##_replace_in_list_##MEMBER(CLASS *p, struct list_head *new) \
{ \
list_replace_init(&((struct S##CLASS *)p)->m_##MEMBER, new); \
} \
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138
list_head
Definition: list.h:58

## TEMPLATE_METHODS_OBJECT_AUX

#define TEMPLATE_METHODS_OBJECT_AUX | ( |  | CLASS,
|  |  | MEMBER,
|  |  | TYPE
| ) |  |

Value:
const TYPE *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const TYPE *s) \
{ \
TYPE *q = TYPE##_dup(s); \
if (!q) return 0; \
TYPE##_delete(((struct S##CLASS *)p)->m_##MEMBER); \
((struct S##CLASS *)p)->m_##MEMBER = q; \
return 1; \
} \
CLASS
struct s_CLASS CLASS
Definition: TemplateInclude.h:138

## Function Documentation

## CLASS_assign()

int CLASS_assign | ( | CLASS * | p,
|  | const CLASS * | q
| ) |  |

Assignment operator

## CLASS_delete()

void CLASS_delete | ( | CLASS * | p | ) |

Destructor

## CLASS_dup()

CLASS* CLASS_dup | ( | const CLASS * | p | ) |

Copy Constructor

## CLASS_new()

CLASS* CLASS_new | ( |  | ) |

Constructor