1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
//! pobsd-parser is a parsing library for parsing the PlayOnBSD Database.
//!
//! This library provides:
//! * A [`Parser`] struct handling the parsing
//! * A [`ParsingMode`] enum to choose between a strict or a relax parsing mode
//! * A [`ParserResult`] struct to handle parsing with and without error
//! * A [`Game`] struct representing a game of a database
//!
//! ### Examples
//! Here is a first example loading a file in relaxed mode (by default).
//! ```no_run
//! extern crate pobsd_parser;
//! use pobsd_parser::{Parser, ParserResult};
//!
//! // Create a parser
//! let parser = Parser::default();
//! // Load the database
//! let parser_result = parser.load_from_file("/path/to/games.db")
//!        .expect("Problem trying to open the file");
//! let games = match parser_result {
//!        ParserResult::WithoutError(games) => games,
//!        ParserResult::WithError(games, _) => games,
//!    };
//! ```
//! The parser can also use a strict mode in which it will stop when encountering
//! a parsing error and returning the games it has processed.
//! ```no_run
//! extern crate pobsd_parser;
//! use pobsd_parser::{Parser, ParserResult, ParsingMode};
//!
//! // Create a paser in strict mode
//! let parser = Parser::new(ParsingMode::Strict);
//! // Load the database
//! let parser_result = parser.load_from_file("/path/to/games.db")
//!        .expect("Problem trying to open the file");
//! let games = match parser_result {
//!     ParserResult::WithoutError(games) => games,
//!     ParserResult::WithError(games, _) => games,
//! };
//! ```
//! The parser can also load from a &str or a String.
//! ```
//! extern crate pobsd_parser;
//! use pobsd_parser::{Parser, ParserResult, ParsingMode};
//!
//! let games = r#"Game	AaaaaAAaaaAAAaaAAAAaAAAAA!!! for the Awesome
//! Cover	AaaaaA_for_the_Awesome_Cover.jpg
//! Engine
//! Setup
//! Runtime	HumblePlay
//! Store	https://www.humblebundle.com/store/aaaaaaaaaaaaaaaaaaaaaaaaa-for-the-awesome
//! Hints	Demo on HumbleBundle store page
//! Genre
//! Tags
//! Year	2011
//! Dev
//! Pub
//! Version
//! Status
//! Added	1970-01-01
//! Updated	1970-01-01
//! IgdbId	12
//! Game	The Adventures of Mr. Hat
//! Cover
//! Engine	godot
//! Setup
//! Runtime	godot
//! Store	https://store.steampowered.com/app/1869200/The_Adventures_of_Mr_Hat/
//! Hints
//! Genre	Puzzle Platformer
//! Tags	indie
//! Year
//! Dev	AX-GAME
//! Pub	Fun Quarter
//! Version	Early Access
//! Status	runs (2022-05-13)
//! Added	2022-05-13
//! Updated	2022-05-13
//! IgdbId	13"#;
//!
//! let parser = Parser::default();
//! let games = match parser.load_from_string(games) {
//!     ParserResult::WithoutError(games) => games,
//!     // Should not panic since the data are fine
//!     ParserResult::WithError(_, _) => panic!(),
//! };
//!
//! ```
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
pub(crate) mod parser_macros;
pub(crate) mod field;
pub mod game;
pub mod parser;
pub(crate) mod split_line;
pub mod store_links;
pub use self::game::Game;
pub use self::parser::Parser;
pub use self::parser::ParserResult;
pub use self::parser::ParsingMode;
pub use self::store_links::Store;
pub use self::store_links::StoreLink;
pub use self::store_links::StoreLinks;