feat: develop the basic functions.
This commit is contained in:
@@ -59,25 +59,27 @@ struct CodeDefinition
|
||||
struct ProblemContent
|
||||
{
|
||||
std::string title;
|
||||
std::string title_slug;
|
||||
std::string titleSlug;
|
||||
std::string content;
|
||||
std::vector<CodeDefinition> codeDefinitions;
|
||||
int questionId;
|
||||
|
||||
ProblemContent(std::string title,
|
||||
std::string title_slug,
|
||||
std::string titleSlug,
|
||||
std::string content,
|
||||
std::vector<CodeDefinition> codeDefinitions,
|
||||
int questionId)
|
||||
: title(std::move(title))
|
||||
, title_slug(std::move(title_slug))
|
||||
, titleSlug(std::move(titleSlug))
|
||||
, content(std::move(content))
|
||||
, codeDefinitions(std::move(codeDefinitions))
|
||||
, questionId(questionId)
|
||||
{
|
||||
}
|
||||
|
||||
std::string formatTemplate(const std::string &templateContent) const;
|
||||
[[nodiscard]] std::string formatTemplate(const std::string &templateContent) const;
|
||||
|
||||
[[nodiscard]] std::string formatFilename() const;
|
||||
};
|
||||
|
||||
struct Fetcher
|
||||
@@ -104,6 +106,8 @@ private:
|
||||
|
||||
[[nodiscard]] std::vector<LeetCodeProblem> getProblems() const;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ProblemContent> fetchProblemContent(const LeetCodeProblem &problem) const;
|
||||
|
||||
/// The callback function used by curl to write the http response content into a string.
|
||||
static size_t httpWriteCallback(void *contents, const size_t size, size_t bufferLength, void *userData)
|
||||
{
|
||||
@@ -121,6 +125,8 @@ private:
|
||||
const LeetCodeProblem &problem);
|
||||
|
||||
static std::string readTemplateFile();
|
||||
|
||||
static bool validateExistedProblem(const ProblemContent &problem);
|
||||
};
|
||||
|
||||
#endif //FETCHER_H
|
Reference in New Issue
Block a user