.. csv-policy-cpp-interface:

CSV Policy C++ Interface
=========================

.. module:: csv_policy_cpp
   :synopsis: C++ interface for CSV Policy configuration.

The C++ interface defines the abstract interface ``iCSVPolicy`` in the ``oo`` namespace. This interface provides formatting configuration options for parsing CSV.

.. contents:: Table of Contents
   :local:
   :depth: 2


Class Definition
----------------

.. cpp:class:: oo::iCSVPolicy

   Abstract interface for CSV Policy configuration.


Character Handling
------------------

.. cpp:function:: virtual char oo::iCSVPolicy::get_delimiter() const

   Gets the current field delimiter.

   :return: The delimiter character.

.. cpp:function:: virtual bool oo::iCSVPolicy::set_delimiter(char delim)

   Sets the field delimiter.

   :param delim: The delimiter character to set.
   :return: ``true`` on success, ``false`` on failure.

.. cpp:function:: virtual char oo::iCSVPolicy::get_quote() const

   Gets the current string escaping character.

   :return: The string escaping character.

.. cpp:function:: virtual void oo::iCSVPolicy::set_quote(char quote)

   Sets the string escaping character.

   :param quote: The string escaping character to set.

.. cpp:function:: virtual void oo::iCSVPolicy::set_no_quote()

   Disables string escaping.

.. cpp:function:: virtual bool oo::iCSVPolicy::is_quote_enabled() const

   Checks whether string escaping is enabled.

   :return: ``true`` if enabled, otherwise ``false``.

.. cpp:function:: virtual void oo::iCSVPolicy::add_trim_char(char trim_char)

   Adds a character to the set of trim characters. If the character appears before or after a field value, it will be stripped during field value parsing.

   :param trim_char: The character to add to the trim set.

.. cpp:function:: virtual void oo::iCSVPolicy::clear_trim_chars()

   Clears all trim characters.


Column Handling
---------------

.. cpp:function:: virtual void oo::iCSVPolicy::ignore_column(int col)

   Marks a column to be ignored during parsing.

   :param col: The 1‑based column index to ignore.


Numeric Formatting
------------------

.. cpp:function:: virtual char oo::iCSVPolicy::decimal_symbol() const

   Gets the current decimal point symbol.

   :return: The decimal point symbol.

.. cpp:function:: virtual void oo::iCSVPolicy::set_decimal_symbol(char symbol)

   Sets the decimal point symbol.

   :param symbol: The decimal point symbol.

.. cpp:function:: virtual char oo::iCSVPolicy::group_separator() const

   Gets the current digit grouping separator (e.g., thousands separator).

   :return: The digit grouping separator.

.. cpp:function:: virtual void oo::iCSVPolicy::set_group_separator(char sep)

   Sets the digit grouping separator (e.g., thousands separator).

   :param sep: The digit grouping separator.

.. cpp:function:: virtual int oo::iCSVPolicy::group_size() const

   Gets the current digit grouping size (e.g., for thousands separators, the group size is 3).

   :return: The grouping size (number of digits per group).

.. cpp:function:: virtual void oo::iCSVPolicy::set_group_size(int size)

   Sets the digit grouping size (e.g., for thousands separators, the group size is 3).

   :param size: The grouping size.


Currency
--------

.. cpp:function:: virtual const char* oo::iCSVPolicy::currency_sign() const

   Gets the current currency sign string (e.g., ``"$"``, ``"USD"``).

   :return: The currency sign string.

.. cpp:function:: virtual void oo::iCSVPolicy::set_currency_sign(const char* sign)

   Sets the currency sign (e.g., ``"$"``, ``"USD"``).

   :param sign: The currency sign string.


Date/Time Format
----------------

.. cpp:function:: virtual const char* oo::iCSVPolicy::datetime_format() const

   Gets the current date/time format string.

   :return: The date/time format string.

.. cpp:function:: virtual void oo::iCSVPolicy::set_datetime_format(const char* fmt)

   Sets the date/time format string.

   :param fmt: The date/time format string (e.g., ``"%Y-%m-%d %H:%M:%S"``).

.. Grid table:

=====================================
Date/Time Format Specifier Reference
=====================================

+------------+------------------------------------------+-------------------+
| Specifier  | Description                              | Example           |
+============+==========================================+===================+
| %Y         | Full year                                | 2026              |
+------------+------------------------------------------+-------------------+
| %y         | Last two digits of year                  | 26                |
+------------+------------------------------------------+-------------------+
| %m         | Two‑digit month (01 to 12)               | 01                |
+------------+------------------------------------------+-------------------+
| %b         | Abbreviated month name (Jan, Feb, ...)   | Jan               |
+------------+------------------------------------------+-------------------+
| %h         | Same as %b                               |                   |
+------------+------------------------------------------+-------------------+
| %B         | Full month name (January, February, ...) | January           |
+------------+------------------------------------------+-------------------+
| %d         | Two‑digit day (01 to 31)                 | 03                |
+------------+------------------------------------------+-------------------+
| %a         | Abbreviated weekday (Sun, Mon, ...)      | Mon               |
+------------+------------------------------------------+-------------------+
| %A         | Full weekday (Sunday, Monday, ...)       | Monday            |
+------------+------------------------------------------+-------------------+
| %H         | Hour in 24‑hour format (00 to 23)        | 14                |
+------------+------------------------------------------+-------------------+
| %I         | Hour in 12‑hour format (01 to 12)        | 02                |
+------------+------------------------------------------+-------------------+
| %M         | Minute (00 to 59)                        | 45                |
+------------+------------------------------------------+-------------------+
| %S         | Second (00 to 59)                        | 30                |
+------------+------------------------------------------+-------------------+
| %p         | AM or PM (with 12‑hour hour)             | AM                |
+------------+------------------------------------------+-------------------+
| %z         | Time zone offset (e.g., +0200 or -0800)  | +0000             |
+------------+------------------------------------------+-------------------+
| %Z         | Time zone name (Only "UTC" is supported) | UTC               |
+------------+------------------------------------------+-------------------+
| %n         | Matches whitespace                       |                   |
+------------+------------------------------------------+-------------------+
| %t         | Matches whitespace                       |                   |
+------------+------------------------------------------+-------------------+
| %.         | Matches any character (skips it)         |                   |
+------------+------------------------------------------+-------------------+
