-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6a3daa
commit 540e04a
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Defines CowlXMLVocab. | ||
* | ||
* @author Ivano Bilenchi | ||
* | ||
* @copyright Copyright (c) 2024 SisInf Lab, Polytechnic University of Bari | ||
* @copyright <http://swot.sisinflab.poliba.it> | ||
* @copyright SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* @file | ||
*/ | ||
|
||
#ifndef COWL_XML_VOCAB_H | ||
#define COWL_XML_VOCAB_H | ||
|
||
#include "cowl_attrs.h" | ||
#include "cowl_macros.h" | ||
|
||
COWL_BEGIN_DECLS | ||
|
||
/// @cond | ||
cowl_struct_decl(CowlString); | ||
/// @endcond | ||
|
||
/// The XML vocabulary. | ||
typedef struct CowlXMLVocab { | ||
|
||
/// XML namespace. | ||
CowlString *ns; | ||
|
||
/// XML prefix. | ||
CowlString *prefix; | ||
|
||
/// xmlns namespace. | ||
CowlString *xmlns_ns; | ||
|
||
/// xmlns prefix. | ||
CowlString *xmlns_prefix; | ||
|
||
} CowlXMLVocab; | ||
|
||
/** | ||
* Returns the XML vocabulary. | ||
* | ||
* @return The XML vocabulary. | ||
*/ | ||
COWL_API | ||
COWL_CONST | ||
CowlXMLVocab const *cowl_xml_vocab(void); | ||
|
||
COWL_END_DECLS | ||
|
||
#endif // COWL_XML_VOCAB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @author Ivano Bilenchi | ||
* | ||
* @copyright Copyright (c) 2024 SisInf Lab, Polytechnic University of Bari | ||
* @copyright <http://swot.sisinflab.poliba.it> | ||
* @copyright SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* @file | ||
*/ | ||
|
||
#include "cowl_xml_vocab.h" | ||
#include "cowl_ret.h" | ||
#include "cowl_vocab_private.h" | ||
#include "cowl_xml_vocab_private.h" | ||
|
||
static CowlXMLVocab vocab; | ||
|
||
static inline cowl_ret cowl_xml_vocab_validate(void) { | ||
if (vocab.ns && vocab.prefix && vocab.xmlns_ns && vocab.xmlns_prefix) return COWL_OK; | ||
return COWL_ERR_MEM; | ||
} | ||
|
||
cowl_ret cowl_xml_vocab_init(void) { | ||
vocab = (struct CowlXMLVocab){ | ||
.ns = cowl_string_vocab_intern("http://www.w3.org/XML/1998/namespace"), | ||
.prefix = cowl_string_vocab("xml"), | ||
.xmlns_ns = cowl_string_vocab_intern("http://www.w3.org/2000/xmlns/"), | ||
.xmlns_prefix = cowl_string_vocab("xmlns"), | ||
}; | ||
|
||
return cowl_xml_vocab_validate(); | ||
} | ||
|
||
void cowl_xml_vocab_deinit(void) { | ||
cowl_string_vocab_free(vocab.ns); | ||
cowl_string_vocab_free(vocab.prefix); | ||
cowl_string_vocab_free(vocab.xmlns_ns); | ||
cowl_string_vocab_free(vocab.xmlns_prefix); | ||
} | ||
|
||
CowlXMLVocab const *cowl_xml_vocab(void) { | ||
return &vocab; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @author Ivano Bilenchi | ||
* | ||
* @copyright Copyright (c) 2024 SisInf Lab, Polytechnic University of Bari | ||
* @copyright <http://swot.sisinflab.poliba.it> | ||
* @copyright SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* @file | ||
*/ | ||
|
||
#ifndef COWL_XML_VOCAB_PRIVATE_H | ||
#define COWL_XML_VOCAB_PRIVATE_H | ||
|
||
#include "cowl_attrs.h" | ||
#include "cowl_ret.h" | ||
#include "cowl_xml_vocab.h" // IWYU pragma: export | ||
|
||
COWL_BEGIN_DECLS | ||
|
||
cowl_ret cowl_xml_vocab_init(void); | ||
void cowl_xml_vocab_deinit(void); | ||
|
||
COWL_END_DECLS | ||
|
||
#endif // COWL_XML_VOCAB_PRIVATE_H |