1 //! \file WikimediaJsonToArticleConverter.h
3 #ifndef WIKIWALKER_WIKIMEDIAJSONTOARTICLECONVERTER_H
4 #define WIKIWALKER_WIKIMEDIAJSONTOARTICLECONVERTER_H
6 #include "ArticleCollection.h"
13 /*! converts a JSON reply from the Wikimedia query links request.
14 * This class only supports JSON format 2! JSON format 1 is not supported
17 class WikimediaJsonToArticleConverter
20 //! Represents the state of the json to article conversion
21 enum class ContinuationStatus
{
22 //! the conversion is completed
24 //! the conversion indicated more data is needed
25 ConversionNeedsMoreData
28 //! Type used for continuation data
29 using continuationData_type
=
30 std::map
<const std::string
, const std::string
>;
32 //! create a new instance
33 WikimediaJsonToArticleConverter() = default;
35 /*! convert JSON data to Article.
36 * convert a string containing json data containing the reply of a Wikimedia
37 * query links request in JSON format 2 to an article with links and puts it
38 * in an ArticleCollection.
39 * \param json json data
40 * \param articleCache reference to an article collection that gets filled
41 * \returns the conversion status. If this is
42 * #ContinuationStatus::ConversionNeedsMoreData, get continuation data with
45 ContinuationStatus
convert(
46 const std::string
& json
,
47 CollectionUtils::ArticleCollection
& articleCache
);
49 /*! Get the continuation data, if
50 * #ContinuationStat::ConversionNeedsMoreData was returned by
52 * \return continuation string
54 continuationData_type
continuationData() const
56 return continuationData_
;
60 //! string required for API operation
61 continuationData_type continuationData_
;
63 } // namespace WikiWalker
64 #endif // WIKIWALKER_WIKIMEDIAJSONTOARTICLECONVERTER_H