Search⌘ K
AI Features

The OrderRecord Class

Explore how the OrderRecord class transforms each CSV line into a structured object by splitting columns and converting elements with C++17 utilities. Understand the use of std::from_chars for error-checked conversion and how these steps support parallel CSV data processing for improved performance.

We'll cover the following...

The main class that is used to compute results is OrderRecord. It’s a direct representation of a line from a CSV file.

C++
class OrderRecord
{
public:
// constructors...
double CalcRecordPrice() const noexcept;
bool CheckDate(const Date& start, const Date& end) const noexcept;
private:
Date mDate;
std::string mCouponCode;
double mUnitPrice{ 0.0 };
double mDiscount{ 0.0 }; // 0... 1.0
unsigned int mQuantity{ 0 };
};

The conversion

Once we ...