Compiler.hh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * https://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef avro_Compiler_hh__
  19. #define avro_Compiler_hh__
  20. #include "Config.hh"
  21. #include <cstdint>
  22. #include <istream>
  23. namespace avro {
  24. class AVRO_DECL InputStream;
  25. /// This class is used to implement an avro spec parser using a flex/bison
  26. /// compiler. In order for the lexer to be reentrant, this class provides a
  27. /// lexer object for each parse. The bison parser also uses this class to
  28. /// build up an avro parse tree as the avro spec is parsed.
  29. class AVRO_DECL ValidSchema;
  30. /// Given a stream containing a JSON schema, compiles the schema to a
  31. /// ValidSchema object. Throws if the schema cannot be compiled to a valid
  32. /// schema
  33. AVRO_DECL void compileJsonSchema(std::istream &is, ValidSchema &schema);
  34. /// Non-throwing version of compileJsonSchema.
  35. ///
  36. /// \return True if no error, false if error (with the error string set)
  37. ///
  38. AVRO_DECL bool compileJsonSchema(std::istream &is, ValidSchema &schema,
  39. std::string &error);
  40. AVRO_DECL ValidSchema compileJsonSchemaFromStream(InputStream &is);
  41. AVRO_DECL ValidSchema compileJsonSchemaFromMemory(const uint8_t *input, size_t len);
  42. AVRO_DECL ValidSchema compileJsonSchemaFromString(const char *input);
  43. AVRO_DECL ValidSchema compileJsonSchemaFromString(const std::string &input);
  44. AVRO_DECL ValidSchema compileJsonSchemaFromFile(const char *filename);
  45. } // namespace avro
  46. #endif