Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_content_type.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework afw_content_type interface support
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 /* Register content type with its id and all of its media types. */
18 AFW_DEFINE(void)
20  const afw_content_type_t *content_type,
21  afw_xctx_t *xctx)
22 {
23  afw_size_t count;
24  const afw_utf8_t *media_type;
25 
26  /* Register content type as its id. */
28  &content_type->content_type_id, content_type,
29  xctx);
30 
31  /* Register content type as all of its media types. */
32  for (count = content_type->media_type_count,
33  media_type = content_type->media_types;
34  count > 0;
35  count--, media_type++)
36  {
37  afw_environment_register_content_type(media_type, content_type,
38  xctx);
39  }
40 }
41 
42 /*
43  * Convert an adaptive value to the raw representation of this content
44  * type using the specified pool.
45  */
46 AFW_DEFINE(const afw_memory_t *)
48  const afw_content_type_t * instance,
49  const afw_value_t * value,
50  const afw_object_options_t *options,
51  const afw_pool_t *p,
52  afw_xctx_t *xctx)
53 {
54  const afw_memory_writer_t *writer;
55 
56  writer = afw_memory_create_writer(p, xctx);
57  afw_content_type_write_value(instance, value, options,
58  writer->context, writer->callback, p, xctx);
59 
60  return afw_memory_writer_retrieve_and_release(writer, xctx);
61 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
#define afw_content_type_write_value(instance, value, options, context, callback, p, xctx)
Call method write_value of interface afw_content_type.
afw_content_type_value_to_raw(const afw_content_type_t *instance, const afw_value_t *value, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Convert value to the raw in specified pool.
afw_content_type_register(const afw_content_type_t *content_type, afw_xctx_t *xctx)
Register content type with its id and all of its media types.
void afw_environment_register_content_type(const afw_utf8_t *type, const afw_content_type_t *content_type, afw_xctx_t *xctx)
Register an content type.
afw_memory_writer_retrieve_and_release(const afw_memory_writer_t *writer, afw_xctx_t *xctx)
Retrieve memory as one chunk from memory writer and release writer.
Definition: afw_memory.c:441
afw_memory_create_writer(const afw_pool_t *p, afw_xctx_t *xctx)
Create a memory writer.
Definition: afw_memory.c:377
Interface afw_content_type public struct.
Struct for memory pointer and size.
Definition: afw_common.h:505
Return value from afw_memory_create_writer().
Definition: afw_memory.h:102
Struct for object processing options.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
Interface afw_xctx public struct.