57 * This is '=' by default. |
57 * This is '=' by default. |
58 */ |
58 */ |
59 char delimiter; |
59 char delimiter; |
60 |
60 |
61 /** |
61 /** |
|
62 * The first comment character. |
|
63 * This is '#' by default. |
|
64 */ |
|
65 char comment1; |
|
66 |
|
67 /** |
|
68 * The second comment character. |
|
69 * This is not set by default. |
|
70 */ |
|
71 char comment2; |
|
72 |
|
73 /** |
|
74 * The third comment character. |
|
75 * This is not set by default. |
|
76 */ |
|
77 char comment3; |
|
78 |
|
79 /* |
62 * The character, when appearing at the end of a line, continues that line. |
80 * The character, when appearing at the end of a line, continues that line. |
63 * This is '\' by default. |
81 * This is '\' by default. |
64 */ |
82 */ |
65 // char continuation; // TODO: line continuation in properties |
83 /** |
66 |
84 * Reserved for future use. |
67 /** |
85 */ |
68 * The first comment character. |
86 char continuation; |
69 * This is '#' by default. |
|
70 */ |
|
71 char comment1; |
|
72 |
|
73 /** |
|
74 * The second comment character. |
|
75 * This is not set by default. |
|
76 */ |
|
77 char comment2; |
|
78 |
|
79 /** |
|
80 * The third comment character. |
|
81 * This is not set by default. |
|
82 */ |
|
83 char comment3; |
|
84 }; |
87 }; |
85 |
88 |
86 /** |
89 /** |
87 * Typedef for the properties config. |
90 * Typedef for the properties config. |
88 */ |
91 */ |
89 typedef struct cx_properties_config_s CxPropertiesConfig; |
92 typedef struct cx_properties_config_s CxPropertiesConfig; |
90 |
93 |
91 /** |
94 /** |
92 * Default properties configuration. |
95 * Default properties configuration. |
93 */ |
96 */ |
|
97 cx_attr_export |
94 extern const CxPropertiesConfig cx_properties_config_default; |
98 extern const CxPropertiesConfig cx_properties_config_default; |
95 |
99 |
96 /** |
100 /** |
97 * Status codes for the properties interface. |
101 * Status codes for the properties interface. |
98 */ |
102 */ |
551 * @return the sink |
560 * @return the sink |
552 * @see cxPropertiesLoad() |
561 * @see cxPropertiesLoad() |
553 */ |
562 */ |
554 cx_attr_nonnull |
563 cx_attr_nonnull |
555 cx_attr_nodiscard |
564 cx_attr_nodiscard |
|
565 cx_attr_export |
556 CxPropertiesSink cxPropertiesMapSink(CxMap *map); |
566 CxPropertiesSink cxPropertiesMapSink(CxMap *map); |
557 |
567 |
558 /** |
568 /** |
559 * Creates a properties source based on an UCX string. |
569 * Creates a properties source based on an UCX string. |
560 * |
570 * |
561 * @param str the string |
571 * @param str the string |
562 * @return the properties source |
572 * @return the properties source |
563 * @see cxPropertiesLoad() |
573 * @see cxPropertiesLoad() |
564 */ |
574 */ |
565 cx_attr_nodiscard |
575 cx_attr_nodiscard |
|
576 cx_attr_export |
566 CxPropertiesSource cxPropertiesStringSource(cxstring str); |
577 CxPropertiesSource cxPropertiesStringSource(cxstring str); |
567 |
578 |
568 /** |
579 /** |
569 * Creates a properties source based on C string with the specified length. |
580 * Creates a properties source based on C string with the specified length. |
570 * |
581 * |
614 * This function tries to read as much data from the source as possible. |
628 * This function tries to read as much data from the source as possible. |
615 * When the source was completely consumed and at least on k/v-pair was found, |
629 * When the source was completely consumed and at least on k/v-pair was found, |
616 * the return value will be #CX_PROPERTIES_NO_ERROR. |
630 * the return value will be #CX_PROPERTIES_NO_ERROR. |
617 * When the source was consumed but no k/v-pairs were found, the return value |
631 * When the source was consumed but no k/v-pairs were found, the return value |
618 * will be #CX_PROPERTIES_NO_DATA. |
632 * will be #CX_PROPERTIES_NO_DATA. |
|
633 * In case the source data ends unexpectedly, the #CX_PROPERTIES_INCOMPLETE_DATA |
|
634 * is returned. In that case you should call this function again with the same |
|
635 * sink and either an updated source or the same source if the source is able to |
|
636 * yield the missing data. |
|
637 * |
619 * The other result codes apply, according to their description. |
638 * The other result codes apply, according to their description. |
620 * |
639 * |
621 * @param prop the properties interface |
640 * @param prop the properties interface |
622 * @param sink the sink |
641 * @param sink the sink |
623 * @param source the source |
642 * @param source the source |
624 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found |
643 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found |
625 * @retval CX_PROPERTIES_READ_INIT_FAILED initializing the source failed |
644 * @retval CX_PROPERTIES_READ_INIT_FAILED initializing the source failed |
626 * @retval CX_PROPERTIES_READ_FAILED reading from the source failed |
645 * @retval CX_PROPERTIES_READ_FAILED reading from the source failed |
627 * @retval CX_PROPERTIES_SINK_FAILED sinking the properties into the sink failed |
646 * @retval CX_PROPERTIES_SINK_FAILED sinking the properties into the sink failed |
628 * @retval CX_PROPERTIES_NO_DATA the source did not provide any key/value pairs |
647 * @retval CX_PROPERTIES_NO_DATA the source did not provide any key/value pairs |
|
648 * @retval CX_PROPERTIES_INCOMPLETE_DATA the source did not provide enough data |
629 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key |
649 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key |
630 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter |
650 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter |
631 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
651 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
632 */ |
652 */ |
633 cx_attr_nonnull |
653 cx_attr_nonnull |
|
654 cx_attr_export |
634 CxPropertiesStatus cxPropertiesLoad( |
655 CxPropertiesStatus cxPropertiesLoad( |
635 CxProperties *prop, |
656 CxProperties *prop, |
636 CxPropertiesSink sink, |
657 CxPropertiesSink sink, |
637 CxPropertiesSource source |
658 CxPropertiesSource source |
638 ); |
659 ); |