Appearance
Content Scheduler
Your Task
Your task is to design a content scheduling system that parses CSV-like configuration data to determine which content type should be published on a given date and platform. The system supports wildcards, defaults, and override precedence rules for flexible content management.
The content scheduling system allows social media managers to specify which type of content should be published on which platform and when. The config is stored in a CSV-like format with three columns: Date, Platform, and Content Type.
Basic Structure
cpp
Date,Platform,ContentType
20250301,Instagram,Video
20250305,Instagram,Image
20250301,Twitter,Text1. Default Platform
cpp
Date,Platform,ContentType
20250301,Default,Text
20250305,Instagram,Video- Purpose: Fallback content type for platforms not explicitly listed
- Behavior: When querying a platform not in the config, return the Default content type
- Example: Querying "LinkedIn" on 20250301 returns "Text"
2. Wildcard Platform (*)
cpp
Date,Platform,ContentType
20250301,*,Video
20250305,Instagram,Image- Purpose: Apply content type to ALL platforms on a given date
- Behavior: Overrides any platform-specific entries for that date
- Example: Querying any platform on 20250301 returns "Video"
Implement a content scheduling system that parses CSV-like configuration data with wildcards and overrides.
cpp
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>
#include <cassert>
// TODO: Implement Content Scheduler with CSV parsing and wildcard support
/**
* @brief Configuration entry structure
*/
struct ConfigEntry {
uint32_t date; // Date in YYYYMMDD format
std::string platform; // Platform name or special value
std::string contentType; // Content type name
ConfigEntry(uint32_t d, const std::string& plat, const std::string& content)
: date(d), platform(plat), contentType(content) {}
};
/**
* @brief Content scheduling system class
*
* Parses CSV-like configuration data and provides query interface
* for determining active content types by date and platform.
*/
class ContentScheduler {
private:
// TODO: Design data structures for efficient storage and lookup
public:
/**
* @brief Parse configuration from input stream
*
* Reads CSV-like data with format: Date,Platform,ContentType
* Handles special platform values: "Default" and "*"
*
* @param input Input stream containing configuration data
*/
void parseConfig(std::istream& input) {
// TODO: Implement CSV parsing
}
/**
* @brief Get active content type for given date and platform
*
* Follows precedence rules:
* 1. Wildcard (*) - highest priority
* 2. Platform-specific entry
* 3. Default - lowest priority
*
* @param date Date in YYYYMMDD format
* @param platform Platform name
* @return Content type name or empty string if not found
*/
std::string getContentType(uint32_t date, const std::string& platform) const {
// TODO: Implement content type lookup with precedence rules
return "";
}
};