redsnow 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +20 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +21 -0
  8. data/README.md +62 -0
  9. data/Rakefile +36 -0
  10. data/Vagrantfile +20 -0
  11. data/ext/snowcrash/Makefile +64 -0
  12. data/ext/snowcrash/Vagrantfile +20 -0
  13. data/ext/snowcrash/bin/snowcrash +0 -0
  14. data/ext/snowcrash/common.gypi +163 -0
  15. data/ext/snowcrash/config.gypi +10 -0
  16. data/ext/snowcrash/config.mk +5 -0
  17. data/ext/snowcrash/configure +213 -0
  18. data/ext/snowcrash/provisioning.sh +15 -0
  19. data/ext/snowcrash/snowcrash.gyp +141 -0
  20. data/ext/snowcrash/src/ActionParser.h +503 -0
  21. data/ext/snowcrash/src/AssetParser.h +215 -0
  22. data/ext/snowcrash/src/BlockUtility.h +186 -0
  23. data/ext/snowcrash/src/Blueprint.h +283 -0
  24. data/ext/snowcrash/src/BlueprintParser.h +347 -0
  25. data/ext/snowcrash/src/BlueprintParserCore.h +190 -0
  26. data/ext/snowcrash/src/BlueprintSection.h +140 -0
  27. data/ext/snowcrash/src/BlueprintUtility.h +126 -0
  28. data/ext/snowcrash/src/CBlueprint.cc +600 -0
  29. data/ext/snowcrash/src/CBlueprint.h +354 -0
  30. data/ext/snowcrash/src/CSourceAnnotation.cc +140 -0
  31. data/ext/snowcrash/src/CSourceAnnotation.h +106 -0
  32. data/ext/snowcrash/src/CodeBlockUtility.h +189 -0
  33. data/ext/snowcrash/src/DescriptionSectionUtility.h +156 -0
  34. data/ext/snowcrash/src/HTTP.cc +46 -0
  35. data/ext/snowcrash/src/HTTP.h +105 -0
  36. data/ext/snowcrash/src/HeaderParser.h +289 -0
  37. data/ext/snowcrash/src/ListBlockUtility.h +273 -0
  38. data/ext/snowcrash/src/ListUtility.h +95 -0
  39. data/ext/snowcrash/src/MarkdownBlock.cc +176 -0
  40. data/ext/snowcrash/src/MarkdownBlock.h +93 -0
  41. data/ext/snowcrash/src/MarkdownParser.cc +266 -0
  42. data/ext/snowcrash/src/MarkdownParser.h +88 -0
  43. data/ext/snowcrash/src/ParameterDefinitonParser.h +570 -0
  44. data/ext/snowcrash/src/ParametersParser.h +252 -0
  45. data/ext/snowcrash/src/Parser.cc +71 -0
  46. data/ext/snowcrash/src/Parser.h +29 -0
  47. data/ext/snowcrash/src/ParserCore.cc +120 -0
  48. data/ext/snowcrash/src/ParserCore.h +82 -0
  49. data/ext/snowcrash/src/PayloadParser.h +672 -0
  50. data/ext/snowcrash/src/Platform.h +54 -0
  51. data/ext/snowcrash/src/RegexMatch.h +32 -0
  52. data/ext/snowcrash/src/ResourceGroupParser.h +195 -0
  53. data/ext/snowcrash/src/ResourceParser.h +584 -0
  54. data/ext/snowcrash/src/SectionUtility.h +142 -0
  55. data/ext/snowcrash/src/Serialize.cc +52 -0
  56. data/ext/snowcrash/src/Serialize.h +69 -0
  57. data/ext/snowcrash/src/SerializeJSON.cc +601 -0
  58. data/ext/snowcrash/src/SerializeJSON.h +21 -0
  59. data/ext/snowcrash/src/SerializeYAML.cc +336 -0
  60. data/ext/snowcrash/src/SerializeYAML.h +21 -0
  61. data/ext/snowcrash/src/SourceAnnotation.h +177 -0
  62. data/ext/snowcrash/src/StringUtility.h +109 -0
  63. data/ext/snowcrash/src/SymbolTable.h +83 -0
  64. data/ext/snowcrash/src/UriTemplateParser.cc +195 -0
  65. data/ext/snowcrash/src/UriTemplateParser.h +243 -0
  66. data/ext/snowcrash/src/Version.h +39 -0
  67. data/ext/snowcrash/src/csnowcrash.cc +23 -0
  68. data/ext/snowcrash/src/csnowcrash.h +38 -0
  69. data/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
  70. data/ext/snowcrash/src/snowcrash.cc +18 -0
  71. data/ext/snowcrash/src/snowcrash.h +41 -0
  72. data/ext/snowcrash/src/snowcrash/snowcrash.cc +170 -0
  73. data/ext/snowcrash/src/win/RegexMatch.cc +78 -0
  74. data/ext/snowcrash/sundown/CONTRIBUTING.md +10 -0
  75. data/ext/snowcrash/sundown/Makefile +83 -0
  76. data/ext/snowcrash/sundown/Makefile.win +33 -0
  77. data/ext/snowcrash/sundown/examples/smartypants.c +72 -0
  78. data/ext/snowcrash/sundown/examples/sundown.c +80 -0
  79. data/ext/snowcrash/sundown/html/houdini.h +37 -0
  80. data/ext/snowcrash/sundown/html/houdini_href_e.c +108 -0
  81. data/ext/snowcrash/sundown/html/houdini_html_e.c +84 -0
  82. data/ext/snowcrash/sundown/html/html.c +647 -0
  83. data/ext/snowcrash/sundown/html/html.h +77 -0
  84. data/ext/snowcrash/sundown/html/html_smartypants.c +389 -0
  85. data/ext/snowcrash/sundown/html_block_names.txt +25 -0
  86. data/ext/snowcrash/sundown/src/autolink.c +297 -0
  87. data/ext/snowcrash/sundown/src/autolink.h +51 -0
  88. data/ext/snowcrash/sundown/src/buffer.c +225 -0
  89. data/ext/snowcrash/sundown/src/buffer.h +96 -0
  90. data/ext/snowcrash/sundown/src/html_blocks.h +206 -0
  91. data/ext/snowcrash/sundown/src/markdown.c +2701 -0
  92. data/ext/snowcrash/sundown/src/markdown.h +147 -0
  93. data/ext/snowcrash/sundown/src/src_map.c +200 -0
  94. data/ext/snowcrash/sundown/src/src_map.h +58 -0
  95. data/ext/snowcrash/sundown/src/stack.c +81 -0
  96. data/ext/snowcrash/sundown/src/stack.h +29 -0
  97. data/ext/snowcrash/sundown/sundown.def +20 -0
  98. data/ext/snowcrash/tools/gyp/AUTHORS +11 -0
  99. data/ext/snowcrash/tools/gyp/DEPS +24 -0
  100. data/ext/snowcrash/tools/gyp/OWNERS +1 -0
  101. data/ext/snowcrash/tools/gyp/PRESUBMIT.py +120 -0
  102. data/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +190 -0
  103. data/ext/snowcrash/tools/gyp/codereview.settings +10 -0
  104. data/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
  105. data/ext/snowcrash/tools/gyp/gyp +8 -0
  106. data/ext/snowcrash/tools/gyp/gyp.bat +5 -0
  107. data/ext/snowcrash/tools/gyp/gyp_main.py +18 -0
  108. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
  109. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
  110. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1063 -0
  111. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  112. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  113. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +267 -0
  114. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +409 -0
  115. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +537 -0
  116. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
  117. data/ext/snowcrash/tools/gyp/pylib/gyp/common.py +521 -0
  118. data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
  119. data/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
  120. data/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +49 -0
  121. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
  122. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  123. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
  124. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1143 -0
  125. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +81 -0
  126. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +335 -0
  127. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +87 -0
  128. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
  129. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2181 -0
  130. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
  131. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3335 -0
  132. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2156 -0
  133. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1224 -0
  134. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  135. data/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2809 -0
  136. data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
  137. data/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +510 -0
  138. data/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +972 -0
  139. data/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
  140. data/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
  141. data/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +292 -0
  142. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1440 -0
  143. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  144. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2889 -0
  145. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  146. data/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
  147. data/ext/snowcrash/tools/gyp/pylintrc +307 -0
  148. data/ext/snowcrash/tools/gyp/samples/samples +81 -0
  149. data/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
  150. data/ext/snowcrash/tools/gyp/setup.py +19 -0
  151. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  152. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  153. data/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +252 -0
  154. data/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
  155. data/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
  156. data/ext/snowcrash/tools/gyp/tools/pretty_sln.py +168 -0
  157. data/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
  158. data/ext/snowcrash/tools/homebrew/snowcrash.rb +11 -0
  159. data/ext/snowcrash/vcbuild.bat +184 -0
  160. data/lib/redsnow.rb +31 -0
  161. data/lib/redsnow/binding.rb +132 -0
  162. data/lib/redsnow/blueprint.rb +365 -0
  163. data/lib/redsnow/object.rb +18 -0
  164. data/lib/redsnow/parseresult.rb +107 -0
  165. data/lib/redsnow/version.rb +4 -0
  166. data/provisioning.sh +20 -0
  167. data/redsnow.gemspec +35 -0
  168. data/test/_helper.rb +15 -0
  169. data/test/fixtures/sample-api-ast.json +97 -0
  170. data/test/fixtures/sample-api.apib +20 -0
  171. data/test/redsnow_binding_test.rb +35 -0
  172. data/test/redsnow_parseresult_test.rb +50 -0
  173. data/test/redsnow_test.rb +285 -0
  174. metadata +358 -0
@@ -0,0 +1,140 @@
1
+ //
2
+ // BlueprintSection.h
3
+ // snowcrash
4
+ //
5
+ // Created by Zdenek Nemec on 11/1/13.
6
+ // Copyright (c) 2013 Apiary Inc. All rights reserved.
7
+ //
8
+
9
+ #ifndef SNOWCRASH_BLUEPRINTSECTION_H
10
+ #define SNOWCRASH_BLUEPRINTSECTION_H
11
+
12
+ #include "MarkdownBlock.h"
13
+ #include "Blueprint.h"
14
+
15
+ namespace snowcrash {
16
+
17
+ /**
18
+ * API Blueprint Sections Types. Block range classification.
19
+ */
20
+ enum SectionType {
21
+ UndefinedSectionType, /// < Undefined section
22
+ BlueprintSectionType, /// < Blueprint overview
23
+ ResourceGroupSectionType, /// < Resource group
24
+ ResourceSectionType, /// < Resource
25
+ ResourceMethodSectionType, /// < Resource & Action combined (abbrev)
26
+ ActionSectionType, /// < Action
27
+ RequestSectionType, /// < Request
28
+ RequestBodySectionType, /// < Request & Payload body combined (abbrev)
29
+ ResponseSectionType, /// < Response
30
+ ResponseBodySectionType, /// < Response & Body combined (abbrev)
31
+ ObjectSectionType, /// < Object (deprecated)
32
+ ObjectBodySectionType, /// < Object & Body combined (abbrev, deprecated)
33
+ ModelSectionType, /// < Model
34
+ ModelBodySectionType, /// < Model & Body combined (abbrev)
35
+ BodySectionType, /// < Payload Body
36
+ DanglingBodySectionType, /// < Dangling Body (unrecognised section considered to be Body)
37
+ SchemaSectionType, /// < Payload Schema
38
+ DanglingSchemaSectionType, /// < Dangling Schema (unrecognised section considered to be Schema)
39
+ HeadersSectionType, /// < Headers
40
+ ForeignSectionType, /// < Foreign, unexpected section
41
+ ParametersSectionType, /// < Parameters
42
+ ParameterDefinitionSectionType, /// < One Parameter definition
43
+ ParameterValuesSectionType /// < Parameter value enumeration
44
+ };
45
+
46
+ /** \returns human readable name for given %SectionType */
47
+ FORCEINLINE std::string SectionName(const SectionType& section) {
48
+ switch (section) {
49
+
50
+ case ModelSectionType:
51
+ case ModelBodySectionType:
52
+ return "model";
53
+
54
+ case ObjectSectionType:
55
+ case ObjectBodySectionType:
56
+ return "object";
57
+
58
+ case RequestSectionType:
59
+ case RequestBodySectionType:
60
+ return "request";
61
+
62
+ case ResponseSectionType:
63
+ case ResponseBodySectionType:
64
+ return "response";
65
+
66
+ case BodySectionType:
67
+ case DanglingBodySectionType:
68
+ return "message-body";
69
+
70
+ case SchemaSectionType:
71
+ case DanglingSchemaSectionType:
72
+ return "message-schema";
73
+
74
+ case HeadersSectionType:
75
+ return "headers";
76
+
77
+ default:
78
+ return "section";
79
+ }
80
+ }
81
+
82
+ /** Markdown block iterator */
83
+ typedef MarkdownBlock::Stack::const_iterator BlockIterator;
84
+
85
+ /**
86
+ * \brief SectionType boundaries.
87
+ *
88
+ * A continuous range of markdown blocks <first, second).
89
+ */
90
+ typedef std::pair<BlockIterator, BlockIterator> SectionBounds;
91
+
92
+
93
+ /**
94
+ * \brief API Blueprint Section Descriptor.
95
+ */
96
+ class BlueprintSection {
97
+
98
+ public:
99
+ BlueprintSection(const SectionBounds& _bounds)
100
+ : type(UndefinedSectionType), bounds(_bounds), m_parent(NULL) {}
101
+
102
+ BlueprintSection(const SectionType _type,
103
+ const SectionBounds& _bounds,
104
+ const BlueprintSection& _parent)
105
+ : type(_type), bounds(_bounds), m_parent(&_parent) {}
106
+
107
+ /** Type of section */
108
+ const SectionType type;
109
+
110
+ /**
111
+ * Maximum boundaries of the section including any subsection.
112
+ */
113
+ const SectionBounds bounds;
114
+
115
+ /**
116
+ * \return True if section's parent is specified, false otherwise.
117
+ */
118
+ bool hasParent() const {
119
+ return (m_parent != NULL);
120
+ }
121
+
122
+ /**
123
+ * \return Parent section, throws exception if no parent is defined.
124
+ */
125
+ const BlueprintSection& parent() const {
126
+ if (!hasParent())
127
+ throw "accessing parent of a root blueprint section";
128
+ return *m_parent;
129
+ }
130
+
131
+ private:
132
+ BlueprintSection();
133
+ BlueprintSection(const BlueprintSection&);
134
+ BlueprintSection& operator=(const BlueprintSection&);
135
+
136
+ const BlueprintSection* m_parent;
137
+ };
138
+ }
139
+
140
+ #endif
@@ -0,0 +1,126 @@
1
+ //
2
+ // BlueprintUtility.h
3
+ // snowcrash
4
+ //
5
+ // Created by Zdenek Nemec on 7/11/13.
6
+ // Copyright (c) 2013 Apiary Inc. All rights reserved.
7
+ //
8
+
9
+ #ifndef SNOWCRASH_BLUEPRINTUTILITY_H
10
+ #define SNOWCRASH_BLUEPRINTUTILITY_H
11
+
12
+ #include <utility>
13
+ #include <functional>
14
+ #include "Blueprint.h"
15
+ #include "HTTP.h"
16
+
17
+ namespace snowcrash {
18
+
19
+ /**
20
+ * \brief Pair firsts matching predicate.
21
+ *
22
+ * Two pairs are a match if their %first matches.
23
+ */
24
+ template <class T>
25
+ struct MatchFirsts : std::binary_function<T, T, bool> {
26
+ bool operator()(const T& left, const T& right) const {
27
+ return left.first == right.first;
28
+ }
29
+ };
30
+
31
+ /**
32
+ * \brief Matches a pair's first against a value.
33
+ */
34
+ template <class T, class R>
35
+ struct MatchFirstWith : std::binary_function<T, R, bool> {
36
+ bool operator()(const T& left, const R& right) const {
37
+ return left.first == right;
38
+ }
39
+ };
40
+
41
+ /** A name matching predicate. */
42
+ template <class T>
43
+ struct MatchName : std::binary_function<T, T, bool> {
44
+ bool operator()(const T& first, const T& second) const {
45
+ return first.name == second.name;
46
+ }
47
+ };
48
+
49
+ /**
50
+ * \brief Payload matching predicate.
51
+ *
52
+ * Matches payloads if their name and media type matches.
53
+ */
54
+ struct MatchPayload : std::binary_function<Payload, Payload, bool> {
55
+ bool operator()(const first_argument_type& left, const second_argument_type& right) const {
56
+
57
+
58
+ if (left.name != right.name)
59
+ return false;
60
+
61
+ // Resolve left content type
62
+ Collection<Header>::const_iterator header;
63
+ header = std::find_if(left.headers.begin(),
64
+ left.headers.end(),
65
+ std::bind2nd(MatchFirstWith<Header, std::string>(),
66
+ HTTPHeaderName::ContentType));
67
+
68
+ std::string leftContentType;
69
+ if (header != left.headers.end())
70
+ leftContentType = header->second;
71
+
72
+ // Resolve right content type
73
+ header = std::find_if(right.headers.begin(),
74
+ right.headers.end(),
75
+ std::bind2nd(MatchFirstWith<Header, std::string>(),
76
+ HTTPHeaderName::ContentType));
77
+
78
+ std::string rightContentType;
79
+ if (header != right.headers.end())
80
+ rightContentType = header->second;
81
+
82
+ return leftContentType == rightContentType;
83
+ }
84
+ };
85
+
86
+ /** URI matching predicate. */
87
+ struct MatchResource : std::binary_function<Resource, Resource, bool> {
88
+ bool operator()(const first_argument_type& first, const second_argument_type& second) const {
89
+ return first.uriTemplate == second.uriTemplate;
90
+ }
91
+ };
92
+
93
+ /** Action matching predicate. */
94
+ template <class T>
95
+ struct MatchAction : std::binary_function<T, T, bool> {
96
+ bool operator()(const T& first, const T& second) const {
97
+ return first.method == second.method;
98
+ }
99
+ };
100
+
101
+ /**
102
+ * \brief Find a request within given action.
103
+ * \param transaction A transaction to check.
104
+ * \param request A request to look for.
105
+ * \return Iterator pointing to the matching request within given method requests.
106
+ */
107
+ FORCEINLINE Collection<Request>::const_iterator FindRequest(const TransactionExample& example, const Request& request) {
108
+ return std::find_if(example.requests.begin(),
109
+ example.requests.end(),
110
+ std::bind2nd(MatchPayload(), request));
111
+ }
112
+
113
+ /**
114
+ * \brief Find a response within responses of a given action.
115
+ * \param transaction A transaction to check.
116
+ * \param response A response to look for.
117
+ * \return Iterator pointing to the matching response within given method requests.
118
+ */
119
+ FORCEINLINE Collection<Response>::const_iterator FindResponse(const TransactionExample& example, const Response& response) {
120
+ return std::find_if(example.responses.begin(),
121
+ example.responses.end(),
122
+ std::bind2nd(MatchPayload(), response));
123
+ }
124
+ }
125
+
126
+ #endif
@@ -0,0 +1,600 @@
1
+ //
2
+ // CBlueprint.cc
3
+ // snowcrash
4
+ // C Implementation of Blueprint.h for binding purposes
5
+ //
6
+ // Created by Ali Khoramshahi on 13/6/14.
7
+ // Copyright (c) 2014 Apiary Inc. All rights reserved.
8
+ //
9
+
10
+ #include "CBlueprint.h"
11
+ #include "snowcrash.h"
12
+
13
+
14
+ SC_API sc_blueprint_t* sc_blueprint_new()
15
+ {
16
+ return AS_TYPE(sc_blueprint_t, ::new snowcrash::Blueprint);
17
+ }
18
+
19
+ SC_API void sc_blueprint_free(sc_blueprint_t* blueprint)
20
+ {
21
+ ::delete AS_TYPE(snowcrash::Blueprint, blueprint);
22
+ }
23
+
24
+ SC_API const char* sc_blueprint_name(const sc_blueprint_t* blueprint)
25
+ {
26
+ const snowcrash::Blueprint* p = AS_CTYPE(snowcrash::Blueprint, blueprint);
27
+ if (!p)
28
+ return "";
29
+
30
+ return p->name.c_str();
31
+ }
32
+
33
+ SC_API const char* sc_blueprint_description(const sc_blueprint_t* blueprint)
34
+ {
35
+ const snowcrash::Blueprint* p = AS_CTYPE(snowcrash::Blueprint, blueprint);
36
+ if (!p)
37
+ return "";
38
+
39
+ return p->description.c_str();
40
+ }
41
+
42
+ /*----------------------------------------------------------------------*/
43
+
44
+ SC_API const sc_metadata_collection_t* sc_metadata_collection_handle(const sc_blueprint_t* blueprint)
45
+ {
46
+ const snowcrash::Blueprint* p = AS_CTYPE(snowcrash::Blueprint, blueprint);
47
+ if (!p)
48
+ return NULL;
49
+
50
+ return AS_CTYPE(sc_metadata_collection_t, &p->metadata);
51
+ }
52
+
53
+ SC_API size_t sc_metadata_collection_size(const sc_metadata_collection_t* metadata)
54
+ {
55
+ const snowcrash::Collection<snowcrash::Metadata>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Metadata>::type, metadata);
56
+ if (!p)
57
+ return 0;
58
+
59
+ return p->size();
60
+ }
61
+
62
+ /*----------------------------------------------------------------------*/
63
+
64
+ SC_API const sc_metadata_t* sc_metadata_handle(const sc_metadata_collection_t* metadata_col, size_t index)
65
+ {
66
+ const snowcrash::Collection<snowcrash::Metadata>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Metadata>::type, metadata_col);
67
+ if (!p)
68
+ return NULL;
69
+
70
+ return AS_CTYPE(sc_metadata_t, &p->at(index));
71
+ }
72
+
73
+ SC_API const char* sc_metadata_key(const sc_metadata_t* metadata)
74
+ {
75
+ const snowcrash::Metadata* p = AS_CTYPE(snowcrash::Metadata, metadata);
76
+ if (!p)
77
+ return "";
78
+
79
+ return p->first.c_str();
80
+ }
81
+
82
+ SC_API const char* sc_metadata_value(const sc_metadata_t* metadata)
83
+ {
84
+ const snowcrash::Metadata* p = AS_CTYPE(snowcrash::Metadata, metadata);
85
+ if (!p)
86
+ return "";
87
+
88
+ return p->second.c_str();
89
+ }
90
+
91
+ /*----------------------------------------------------------------------*/
92
+
93
+ SC_API const sc_resource_groups_collection_t* sc_resource_groups_collection_handle(const sc_blueprint_t* blueprint)
94
+ {
95
+ const snowcrash::Blueprint* p = AS_CTYPE(snowcrash::Blueprint, blueprint);
96
+ if (!p)
97
+ return NULL;
98
+
99
+ return AS_CTYPE(sc_resource_groups_collection_t, &p->resourceGroups);
100
+ }
101
+
102
+ SC_API size_t sc_resource_groups_collection_size(const sc_resource_groups_collection_t* resource)
103
+ {
104
+ const snowcrash::Collection<snowcrash::ResourceGroup>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::ResourceGroup>::type, resource);
105
+ if (!p)
106
+ return 0;
107
+
108
+ return p->size();
109
+ }
110
+
111
+ /*----------------------------------------------------------------------*/
112
+
113
+ SC_API const sc_resource_groups_t* sc_resource_groups_handle(const sc_resource_groups_collection_t* resource, size_t index)
114
+ {
115
+ const snowcrash::Collection<snowcrash::ResourceGroup>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::ResourceGroup>::type, resource);
116
+ if (!p)
117
+ return NULL;
118
+
119
+ return AS_CTYPE(sc_resource_groups_t, &p->at(index));
120
+ }
121
+
122
+ SC_API const char* sc_resource_groups_name(const sc_resource_groups_t* handle)
123
+ {
124
+ const snowcrash::ResourceGroup* p = AS_CTYPE(snowcrash::ResourceGroup, handle);
125
+ if(!p)
126
+ return "";
127
+
128
+ return p->name.c_str();
129
+ }
130
+
131
+ SC_API const char* sc_resource_groups_description(const sc_resource_groups_t* handle)
132
+ {
133
+ const snowcrash::ResourceGroup* p = AS_CTYPE(snowcrash::ResourceGroup, handle);
134
+ if(!p)
135
+ return "";
136
+
137
+ return p->description.c_str();
138
+ }
139
+
140
+ /*----------------------------------------------------------------------*/
141
+
142
+ SC_API const sc_resource_collection_t* sc_resource_collection_handle(const sc_resource_groups_t* handle)
143
+ {
144
+ const snowcrash::ResourceGroup* p = AS_CTYPE(snowcrash::ResourceGroup, handle);
145
+ if (!p)
146
+ return NULL;
147
+
148
+ return AS_CTYPE(sc_resource_collection_t, &p->resources);
149
+ }
150
+
151
+ SC_API size_t sc_resource_collection_size(const sc_resource_collection_t* resource)
152
+ {
153
+ const snowcrash::Collection<snowcrash::Resource>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Resource>::type, resource);
154
+ if (!p)
155
+ return 0;
156
+
157
+ return p->size();
158
+ }
159
+
160
+ /*----------------------------------------------------------------------*/
161
+
162
+ SC_API const sc_resource_t* sc_resource_handle(const sc_resource_collection_t* resource, size_t index)
163
+ {
164
+ const snowcrash::Collection<snowcrash::Resource>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Resource>::type, resource);
165
+ if (!p)
166
+ return NULL;
167
+
168
+ return AS_CTYPE(sc_resource_t, &p->at(index));
169
+ }
170
+
171
+ SC_API const char* sc_resource_uritemplate(const sc_resource_t* handle)
172
+ {
173
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
174
+ if(!p)
175
+ return "";
176
+
177
+ return p->uriTemplate.c_str();
178
+ }
179
+
180
+ SC_API const char* sc_resource_name(const sc_resource_t* handle)
181
+ {
182
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
183
+ if(!p)
184
+ return "";
185
+
186
+ return p->name.c_str();
187
+ }
188
+
189
+ SC_API const char* sc_resource_description(const sc_resource_t* handle)
190
+ {
191
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
192
+ if(!p)
193
+ return "";
194
+
195
+ return p->description.c_str();
196
+ }
197
+
198
+ /*----------------------------------------------------------------------*/
199
+
200
+ SC_API const sc_payload_collection_t* sc_payload_collection_handle_requests(const sc_transaction_example_t* handle)
201
+ {
202
+ const snowcrash::TransactionExample* p = AS_CTYPE(snowcrash::TransactionExample, handle);
203
+ if (!p)
204
+ return NULL;
205
+
206
+ return AS_CTYPE(sc_payload_collection_t, &p->requests);
207
+ }
208
+
209
+ SC_API const sc_payload_collection_t* sc_payload_collection_handle_responses(const sc_transaction_example_t* handle)
210
+ {
211
+ const snowcrash::TransactionExample* p = AS_CTYPE(snowcrash::TransactionExample, handle);
212
+ if (!p)
213
+ return NULL;
214
+
215
+ return AS_CTYPE(sc_payload_collection_t, &p->responses);
216
+ }
217
+
218
+ SC_API size_t sc_payload_collection_size(const sc_payload_collection_t* handle)
219
+ {
220
+ const snowcrash::Collection<snowcrash::Payload>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Payload>::type, handle);
221
+ if (!p)
222
+ return 0;
223
+
224
+ return p->size();
225
+ }
226
+
227
+ /*----------------------------------------------------------------------*/
228
+
229
+ SC_API const sc_payload_t* sc_payload_handle(const sc_payload_collection_t* handle, size_t index)
230
+ {
231
+ const snowcrash::Collection<snowcrash::Payload>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Payload>::type, handle);
232
+ if(!p)
233
+ return 0;
234
+
235
+ return AS_CTYPE(sc_payload_t, &p->at(index));
236
+ }
237
+
238
+ SC_API const sc_payload_t* sc_payload_handle_resource(const sc_resource_t* handle)
239
+ {
240
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
241
+ if(!p)
242
+ return NULL;
243
+
244
+ return AS_CTYPE(sc_payload_t, &p->model);
245
+ }
246
+
247
+ SC_API const char* sc_payload_name(const sc_payload_t* handle)
248
+ {
249
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
250
+ if(!p)
251
+ return "";
252
+
253
+ return p->name.c_str();
254
+ }
255
+
256
+ SC_API const char* sc_payload_description(const sc_payload_t* handle)
257
+ {
258
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
259
+ if(!p)
260
+ return "";
261
+
262
+ return p->description.c_str();
263
+ }
264
+
265
+ SC_API const char* sc_payload_body(const sc_payload_t* handle)
266
+ {
267
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
268
+ if(!p)
269
+ return "";
270
+
271
+ return p->body.c_str();
272
+ }
273
+
274
+ SC_API const char* sc_payload_schema(const sc_payload_t* handle)
275
+ {
276
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
277
+ if(!p)
278
+ return "";
279
+
280
+ return p->schema.c_str();
281
+ }
282
+
283
+ /*----------------------------------------------------------------------*/
284
+
285
+ SC_API const sc_parameter_collection_t* sc_parameter_collection_handle_payload(const sc_payload_t* handle)
286
+ {
287
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
288
+ if(!p)
289
+ return NULL;
290
+
291
+ return AS_CTYPE(sc_parameter_collection_t, &p->parameters);
292
+ }
293
+
294
+ SC_API const sc_parameter_collection_t* sc_parameter_collection_handle_resource(const sc_resource_t* handle)
295
+ {
296
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
297
+ if(!p)
298
+ return NULL;
299
+
300
+ return AS_CTYPE(sc_parameter_collection_t, &p->parameters);
301
+ }
302
+
303
+ SC_API const sc_parameter_collection_t* sc_parameter_collection_handle_action(const sc_action_t* handle)
304
+ {
305
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
306
+ if(!p)
307
+ return NULL;
308
+
309
+ return AS_CTYPE(sc_parameter_collection_t, &p->parameters);
310
+ }
311
+
312
+ SC_API size_t sc_parameter_collection_size(const sc_parameter_collection_t* handle)
313
+ {
314
+ const snowcrash::Collection<snowcrash::Parameter>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Parameter>::type, handle);
315
+ if(!p)
316
+ return 0;
317
+
318
+ return p->size();
319
+ }
320
+
321
+ /*----------------------------------------------------------------------*/
322
+
323
+ SC_API const sc_parameter_t* sc_parameter_handle(const sc_parameter_collection_t* handle, size_t index)
324
+ {
325
+ const snowcrash::Collection<snowcrash::Parameter>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Parameter>::type, handle);
326
+ if(!p)
327
+ return 0;
328
+
329
+ return AS_CTYPE(sc_parameter_t, &p->at(index));
330
+ }
331
+
332
+ SC_API const char* sc_parameter_name(const sc_parameter_t* handle)
333
+ {
334
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
335
+ if (!p)
336
+ return "";
337
+
338
+ return p->name.c_str();
339
+ }
340
+
341
+ SC_API const char* sc_parameter_description(const sc_parameter_t* handle)
342
+ {
343
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
344
+ if (!p)
345
+ return "";
346
+
347
+ return p->description.c_str();
348
+ }
349
+
350
+ SC_API const char* sc_parameter_type(const sc_parameter_t* handle)
351
+ {
352
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
353
+ if (!p)
354
+ return "";
355
+
356
+ return p->type.c_str();
357
+ }
358
+
359
+ SC_API sc_parameter_use sc_parameter_parameter_use(const sc_parameter_t* handle)
360
+ {
361
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
362
+ if (!p)
363
+ return SC_UNDEFINED_PARAMETER_USE;
364
+
365
+ return (sc_parameter_use)p->use;
366
+ }
367
+
368
+ SC_API const char* sc_parameter_default_value(const sc_parameter_t* handle)
369
+ {
370
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
371
+ if (!p)
372
+ return "";
373
+
374
+ return p->defaultValue.c_str();
375
+ }
376
+
377
+ SC_API const char* sc_parameter_example_value(const sc_parameter_t* handle)
378
+ {
379
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
380
+ if (!p)
381
+ return "";
382
+
383
+ return p->exampleValue.c_str();
384
+ }
385
+
386
+ /*----------------------------------------------------------------------*/
387
+
388
+ SC_API const sc_value_collection_t* sc_value_collection_handle(const sc_parameter_t* handle)
389
+ {
390
+ const snowcrash::Parameter* p = AS_CTYPE(snowcrash::Parameter, handle);
391
+ if (!p)
392
+ return NULL;
393
+
394
+ return AS_CTYPE(sc_value_collection_t, &p->values);
395
+ }
396
+
397
+ SC_API size_t sc_value_collection_size(const sc_value_collection_t* handle)
398
+ {
399
+ const snowcrash::Collection<snowcrash::Value>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Value>::type, handle);
400
+ if (!p)
401
+ return 0;
402
+
403
+ return p->size();
404
+ }
405
+
406
+ /*----------------------------------------------------------------------*/
407
+
408
+ SC_API const sc_value_t* sc_value_handle(const sc_value_collection_t* handle, size_t index)
409
+ {
410
+ const snowcrash::Collection<snowcrash::Value>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Value>::type, handle);
411
+ if (!p)
412
+ return NULL;
413
+
414
+ return AS_CTYPE( sc_value_t, &p->at(index));
415
+ }
416
+
417
+ SC_API const char* sc_value_string(const sc_value_t* handle)
418
+ {
419
+ const snowcrash::Value* p = AS_CTYPE(snowcrash::Value, handle);
420
+ if(!p)
421
+ return "";
422
+
423
+ return p->c_str();
424
+ }
425
+
426
+ /*----------------------------------------------------------------------*/
427
+
428
+ SC_API const sc_header_collection_t* sc_header_collection_handle_payload(const sc_payload_t* handle)
429
+ {
430
+ const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
431
+ if (!p)
432
+ return NULL;
433
+
434
+ return AS_CTYPE(sc_header_collection_t, &p->headers);
435
+ }
436
+
437
+ SC_API const sc_header_collection_t* sc_header_collection_handle_resource(const sc_resource_t* handle)
438
+ {
439
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
440
+ if (!p)
441
+ return NULL;
442
+
443
+ return AS_CTYPE(sc_header_collection_t, &p->headers);
444
+ }
445
+
446
+ SC_API const sc_header_collection_t* sc_header_collection_handle_action(const sc_action_t* handle)
447
+ {
448
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
449
+ if (!p)
450
+ return NULL;
451
+
452
+ return AS_CTYPE(sc_header_collection_t, &p->headers);
453
+ }
454
+
455
+ SC_API size_t sc_header_collection_size(const sc_header_collection_t* handle)
456
+ {
457
+ const snowcrash::Collection<snowcrash::Header>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Header>::type, handle);
458
+ if (!p)
459
+ return 0;
460
+
461
+ return p->size();
462
+ }
463
+
464
+ /*----------------------------------------------------------------------*/
465
+
466
+ SC_API const sc_header_t* sc_header_handle(const sc_header_collection_t* handle, size_t index)
467
+ {
468
+ const snowcrash::Collection<snowcrash::Header>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Header>::type, handle);
469
+ if (!p)
470
+ return NULL;
471
+
472
+ return AS_CTYPE( sc_header_t, &p->at(index));
473
+ }
474
+
475
+ SC_API const char* sc_header_key(const sc_header_t* handle)
476
+ {
477
+ const snowcrash::Header* p = AS_CTYPE(snowcrash::Header, handle);
478
+ if(!p)
479
+ return "";
480
+
481
+ return p->first.c_str();
482
+ }
483
+
484
+ SC_API const char* sc_header_value(const sc_header_t* handle)
485
+ {
486
+ const snowcrash::Header* p = AS_CTYPE(snowcrash::Header, handle);
487
+ if(!p)
488
+ return "";
489
+
490
+ return p->second.c_str();
491
+ }
492
+
493
+ /*----------------------------------------------------------------------*/
494
+
495
+ SC_API const sc_action_collection_t* sc_action_collection_handle(const sc_resource_t* handle)
496
+ {
497
+ const snowcrash::Resource* p = AS_CTYPE(snowcrash::Resource, handle);
498
+ if(!p)
499
+ return NULL;
500
+
501
+ return AS_CTYPE(sc_action_collection_t, &p->actions);
502
+ }
503
+
504
+ SC_API size_t sc_action_collection_size(const sc_action_collection_t* handle)
505
+ {
506
+ const snowcrash::Collection<snowcrash::Action>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Action>::type, handle);
507
+ if (!p)
508
+ return 0;
509
+
510
+ return p->size();
511
+ }
512
+
513
+ /*----------------------------------------------------------------------*/
514
+
515
+ SC_API const sc_action_t* sc_action_handle(const sc_action_collection_t* handle, size_t index)
516
+ {
517
+ const snowcrash::Collection<snowcrash::Action>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::Action>::type, handle);
518
+ if(!p)
519
+ return 0;
520
+
521
+ return AS_CTYPE(sc_action_t, &p->at(index));
522
+ }
523
+
524
+ SC_API const char* sc_action_httpmethod(const sc_action_t* handle)
525
+ {
526
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
527
+ if (!p)
528
+ return "";
529
+
530
+ return p->method.c_str();
531
+ }
532
+
533
+ SC_API const char* sc_action_name(const sc_action_t* handle)
534
+ {
535
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
536
+ if (!p)
537
+ return "";
538
+
539
+ return p->name.c_str();
540
+ }
541
+
542
+ SC_API const char* sc_action_description(const sc_action_t* handle)
543
+ {
544
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
545
+ if (!p)
546
+ return "";
547
+
548
+ return p->description.c_str();
549
+ }
550
+
551
+ /*----------------------------------------------------------------------*/
552
+
553
+ SC_API const sc_transaction_example_collection_t* sc_transaction_example_collection_handle(const sc_action_t* handle)
554
+ {
555
+ const snowcrash::Action* p = AS_CTYPE(snowcrash::Action, handle);
556
+ if(!p)
557
+ return NULL;
558
+
559
+ return AS_CTYPE(sc_transaction_example_collection_t, &p->examples);
560
+ }
561
+
562
+ SC_API size_t sc_transaction_example_collection_size(const sc_transaction_example_collection_t* handle)
563
+ {
564
+ const snowcrash::Collection<snowcrash::TransactionExample>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::TransactionExample>::type, handle);
565
+ if (!p)
566
+ return 0;
567
+
568
+ return p->size();
569
+ }
570
+
571
+ /*----------------------------------------------------------------------*/
572
+
573
+ SC_API const sc_transaction_example_t* sc_transaction_example_handle(const sc_transaction_example_collection_t* handle, size_t index)
574
+ {
575
+ const snowcrash::Collection<snowcrash::TransactionExample>::type* p = AS_CTYPE(snowcrash::Collection<snowcrash::TransactionExample>::type, handle);
576
+ if(!p)
577
+ return 0;
578
+
579
+ return AS_CTYPE(sc_transaction_example_t, &p->at(index));
580
+ }
581
+
582
+ SC_API const char* sc_transaction_example_name(const sc_transaction_example_t* handle)
583
+ {
584
+ const snowcrash::TransactionExample* p = AS_CTYPE(snowcrash::TransactionExample, handle);
585
+ if (!p)
586
+ return "";
587
+
588
+ return p->name.c_str();
589
+ }
590
+
591
+ SC_API const char* sc_transaction_example_description(const sc_transaction_example_t* handle)
592
+ {
593
+ const snowcrash::TransactionExample* p = AS_CTYPE(snowcrash::TransactionExample, handle);
594
+ if (!p)
595
+ return "";
596
+
597
+ return p->description.c_str();
598
+ }
599
+
600
+ /*----------------------------------------------------------------------*/