/** @page basic_data_types Basic Data Types

    @tableofcontents

    The following are the basic data types in %Qore (see @ref container_data_types and @ref code_data_types):

    <b>Basic Data Types</b>
    |!Type|!Description|!Example|!Default Value
    |@ref boolean|@ref True "True" or @ref False "False" value|@ref True "True"|@ref False "False"
    |@ref string|A sequence of characters with a @ref character_encoding "character encoding"|\c "string"|Empty string (i.e. \c "")
    |@ref integer|A 64-bit signed integer|\c 1|\c 0
    |@ref float|A double-precision floating-point number|\c 1.00023|\c 0.0
    |@ref number|An arbitrary-precision number|\c 5.23928173726123e50n|\c 0.0n
    |@ref date|@ref absolute_dates "absolute" (with an associated @ref time_zones "time zone") or @ref relative_dates "relative" date/time values, both with resolution to the microsecond|\c 2010-05-10T18:35:21.001456-07:00|\c 1970-01-01Z
    |@ref binary|An opaque binary object|<tt><23deadbeef></tt>|an empty object of size 0
    |@ref null|Corresponds to a \c NULL value in a database query (not equivalent to @ref nothing|@ref NULL|@ref NULL
    |@ref nothing|Represents the state of a variable having no value or function returning no value (not equivalent to @ref null)|@ref NOTHING|@ref NOTHING

    <hr>
    @section boolean Boolean

    @par Description:
    The Boolean type can have two values, @ref True "True" and @ref False "False".\n\n

    When converting other types to a Boolean, %Qore uses Perl-style boolean conversion, based on an interpretation of the source value and taking into account its type (for example, when this option is set, an empty @ref string "string", @ref hash "hash", or @ref list "list" is always @ref False, whereas if these are not empty they are interpreted as @ref True "True"); this way is considered to be more intuitive by most prorammers, so much so that the original strict mathematical interpretation of boolean values is considered to be a design bug in qore; see @ref perl-bool-eval "%perl-bool-eval" for more information.

    @par Immediate Value Example:
    @ref True

    @par Pseudo Class for Type Boolean:
    @ref Qore::zzz8boolzzz9

    @par Type Code:
    @ref Qore::NT_BOOLEAN

    @par Type Name:
    \c "bool"

    @see @ref bool_type, @ref softbool_type

    @subsection True True

    The keyword \c \b True stands for the boolean value true.

    @subsection False False

    The keyword \c \b False stands for the boolean value false.

    <hr>
    @section string String

    @par Description:
    String values are specified with text between double or single quotes. Text between double quotes is subject to interpretation of escape characters; text between single quotes is not.\n\n
    Strings are assumed by default to have the encoding given by the \c QORE_CHARSET or the \c LANG environment variable (see @ref environment_variables). If neither of these variables is set, then all strings will be assumed to have \c UTF-8 encoding.\n\n
    For detailed information on %Qore character encoding handling, please see @ref character_encoding .\n\n
    It is legal to specify a string literal with newline characters like the following:\n
    @code{.py}
str = "this string is
on more than 1 line";
    @endcode \n
    See @ref string_escape_chars "string escape characters" for a description of escape characters in double-quoted strings.\n\n
    Internally, strings are stored as a pointer to a sequence of bytes terminated by a null (or zero byte), an unsigned integer giving the length of the string, and a pointer to an object giving the string's @ref character_encoding "character encoding".\n\n
    <string>::strlen() is a constant-time operation (ie <i>O(1)</i>), however if the string has a multi-byte encoding, then <string>::length() (returning the length of the string in characters, not bytes) computational complexity is <i>O(n)</i> (however if the character encoding is a single-byte encoding <string>::length() is also <i>O(1)</i>).\n\n

    @par Immediate Value Example:
    \c "this is a string"

    @par Pseudo Class for Type String:
    @ref Qore::zzz8stringzzz9

    @par Type Code:
    @ref Qore::NT_STRING

    @par Type Name:
    \c "string"

    @anchor string_slicing
    @par String slicing:
    As an alternative way of acquiring substrings, strings can be "sliced" by dereferencing them using the @ref list_element_operator "[] operator" with a range or a list, as in the following examples:\n
    @code{.py}
string str = "hello";

# Creates a substring with the first two characters of the original string
string str1a = str[0..1];
string str1b = str[0,1];
string str1c = str[..1];
printf("string 1a: %y\n", str1a);
printf("string 1b: %y\n", str1b);
printf("string 1c: %y\n", str1c);

# Creates a substring with the last two characters of the original string in reverse order
string str2a = str[4..3];
string str2b = str[4,3];
printf("string 2a: %y\n", str2a);
printf("string 2b: %y\n", str2b);

# Creates a substring from different characters in the string
string str3 = str[4,3..1,0];
printf("string 3: %y\n", str3);

# -------------------------
# the output is as follows:

string 1a: "he"
string 1b: "he"
string 1c: "he"
string 2a: "ol"
string 2b: "ol"
string 3: "olleh"
    @endcode \n

    When making a substring with a list of character offsets and referring to a character offset that does not exist,
    no characters are added to the output string; these references are ignored.

    @see
    - @ref string_type, @ref softstring_type
    - @ref string_functions

    <hr>
    @section integer Integer

    @par Description:
    %Qore integers are 64-bit signed integers.

    @par Immediate Value Example:
    \c 100

    @par Pseudo Class for Type Integer:
    @ref Qore::zzz8intzzz9

    @par Type Code:
    @ref Qore::NT_INT

    @par Type Name:
    \c "integer"

    @see
    - @ref int_type, @ref softint_type
    - @ref Qore::MAXINT, @ref Qore::MININT

    <hr>
    @section float Float

    @par Description:
    %Qore floats are double precision floating-point numbers (C/C++ type \a double), normally a 64-bit value.

    @par Immediate Value Examples:
    - \c -500.494
    - \c 2.35e10

    @par Pseudo Class for Type Float:
    @ref Qore::zzz8floatzzz9

    @par Type Code:
    @ref Qore::NT_FLOAT

    @par Type Name:
    \c "float"

    @see
    - @ref float_type, @ref softfloat_type
    - @ref math_functions

    <hr>
    @section number Number

    @par Description:
    %Qore "number" values are arbitrary-precision numbers as provided by the <a href="http://gmplib.org">GMP</a> and <a href="http://www.mpfr.org">MPFR</a> libraries. Inside, they are implemented as floating-point values and therefore comparing them entails the same problems as comparing floats. You should not compare two number values for equality directly.\n\n
    Operations with number values are generally slower than those with @ref float "floats" but support far greater accuracy.  To give an immediate number value; write an integer or floating-point value and append an \c "n" to it, designating a "number" value.\n\n
    In numeric operations where at least one argument is a number type, the other operands will generally be automatically converted to a number type and the result of the operation will also be a number type.  When an operator acts on two values of type number, the result of the operation has the precision of the operand with the greatest precision.

    @par Immediate Value Example:
    - \c -500.494n
    - \c 2.35e10n

    @par Pseudo Class for Type Number:
    @ref Qore::zzz8numberzzz9

    @par Type Code:
    @ref Qore::NT_NUMBER

    @par Type Name:
    \c "number"

    @see
    - @ref number_type, @ref softnumber_type
    - @ref math_functions

    @since %Qore 0.8.6 introduced the number type and integration with the <a href="http://gmplib.org">GMP</a> and <a href="http://www.mpfr.org">MPFR</a> libraries

    <hr>
    @section date Date

    @par Description:
    %Qore date/time values have date and time components supporting a resolution to the microsecond and can be either @ref absolute_dates "absolute" or @ref relative_dates "relative".

    @par Immediate Value Examples:
    - <tt>2012-02-17T19:05:54+01:00</tt>

    @par Pseudo Class for Type Date:
    @ref Qore::zzz8datezzz9

    @par Type Code:
    @ref Qore::NT_DATE

    @par Type Name:
    \c "date"

    @see
    - @ref date_and_time_functions for a list of functions related to date/time processing
    - @ref date_time_arithmetic
    - @ref time_zones

    @subsection absolute_dates Absolute Date/Time Values
    Absolute date/time values specify a specific point in time in a certain time zone, such as January 1, 2005 10:35:00 +01:00. They are stored interally as a 64-bit signed offset from the %Qore epoch (\c 1970-01-01Z), a non-negative 4-byte integer for microseconds, and a pointer to a time zone description object that provides the UTC offset and daylight savings time information (see @ref time_zones for more information). Note that all absolute date/time values in %Qore are stored internally in UTC and are converted for display purposes to the representation of wall time in their tagged time zone.

    Absolute date/time values can be specified with a syntax based on <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> date formats as follows:

    @verbatim
YYYY-MM-DD[THH:mm:SS[.n*]][Z|[+-]HH[:mm[:SS]]]@endverbatim

    Note that if no time zone information is given, the local time zone will be assumed. If a time zone UTC offset is given, it is given in units of time east of UTC (i.e. \c +05:00 means five hours east of UTC).

    Or an alternative format (with a \c '-' instead of a \c 'T' to separate the time component):

    @verbatim
YYYY-MM-DD[-HH:mm:SS[.n*]][Z|[+-]HH[:mm[:SS]]]@endverbatim

    for example, for just the date without a time component (assumed to be midnight on the given date in the local time zone):
    - \c <tt>2010-05-26</tt>

    for just the date in UTC, without a time component:
    - \c <tt>2010-05-26Z</tt>

    or, for just the time, without a date component (note that in this case the date component will be set to Jan 1, 1970, in order for time arithmetic to function properly and will also be tagged with the local time zone):
    - <tt>20:05:10.458342</tt>

    Some further examples (note that the date/time values without a time zone specification here are tagged with the local time zone):

    @code{.py}
prompt% qore -X '2005-03-29-18:12:25'
2005-03-29 18:12:25 Tue +02:00 (CEST)
prompt% qore -X '0512-01-01T01:49:59.002213Z'
0512-01-01 01:49:59.002213 Fri Z (UTC)
prompt% qore -X '2005-03-29'
2005-03-29 00:00:00 Tue +02:00 (CEST)
prompt% qore -X '18:35:26+08:00'
1970-01-01 18:35:26 Thu +08:00 (+08)
    @endcode

    The year must be a four-digit number, and all other values except microseconds must be two-digit numbers. If microseconds are present, at least one and up to 6 digits may be given after the decimal point. Pad the numbers with leading zeros if the numbers are smaller than the required number of digits. The hour component must be in 24-hour time format. Except for the month and day values, all other values start with 0 (hour = 00 - 23, minute and second: 00 - 59). Any deviation from this format will cause a parse exception.

    When a date/time value is converted to an integer or vice-versa, a 64-bit offset in seconds from the start of the "epoch" is used for the conversion. %Qore's "zero date" (the start of %Qore's "epoch") is January 1, 1970 UTC. When calculating second offsets from this date, a 64-bit integer is used.

    @note The default local time zone for qore is set when the qore library is initialized; see @ref time_zones for more information.

    @subsection relative_dates Relative Date/Time Values (Durations)
    Relative dates (durations) are normally used for date addition and subtraction. See @ref date_time_arithmetic for more information.

    Internally, durations are stored as a set of seven discrete signed integer values, one each for years, months, days, hours, minutes, seconds, and microseconds.

    There are 3 different formats understood by the %Qore parser for describing literal durations in %Qore as follows:
    - @ref single_reldates "Single Relative Time Format" (ex: <tt>750ms</tt>; %Qore-specific)
    - @ref short_reldates "Short Relative Time Format" (ex: <tt>P3DT21H</tt>; based on <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>)
    - @ref long_reldates "Long Relative Time Format" (ex: <tt>P0001-03-00T00:00:04</tt>; based on <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>)

    @subsubsection single_reldates Single Relative Time Format
    A single relative date/time value (or a duration) may be specified as follows (note that this format is specific to %Qore and not based on <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>):
    - @verbatim <integer><date component specifier>@endverbatim
    .
    <b>Examples:</b>
    - \c 250ms: 250 milliseconds
    - \c 30s: 30 seconds
    - \c 2m: 2 minutes
    - \c 19.1s: 19 seconds and 100 milliseconds
    .
    Such values are recommended to give to functions and methods taking a timeout value as the units are then clear in the source code (whereas if an integer is given, it may not be clear that the function or method expects a value in milliseconds, for example); for example:
    @code{.py}
auto val = q.pop(20s);
    @endcode
    is clearer than the alternative with an argument given as a value in implied milliseconds to the @ref Qore::Thread::Queue::pop(timeout) "Queue::pop()" method:
    @code{.py}
auto val = q.pop(20000);
    @endcode
    <b>Date Specifiers For Single Values For Relative Dates (non-<a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> syntax)</b>
    |!Component|!Meaning|!Example|!Description
    |\c Y|Years|\c 2Y|2 Years
    |\c M|Months|\c 3M|3 Months
    |\c D|Days|\c 10D|10 Days
    |\c h|Hours|\c 15h|15 hours
    |\c m|Minutes|\c 25m|25 minutes
    |\c s|Seconds|\c 19.1s|19 seconds and 100 milliseconds
    |\c ms|Milliseconds|\c 250ms|250 milliseconds
    |\c us|Microseconds|\c 21194us|21194 microseconds

    @note In this relative date/time format, only seconds accept a fractional component

    @subsubsection short_reldates Short Relative Time Format
    This and the next duration format for composite relative date/time values are both based on <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>.\n\n
    This first format has the following syntax:
    - \c PnYnMnDTnHnMnS
    .
    Each element above is optional, but at least one element must be present. Note that \c "M" means months when before the \c "T" and minutes when found after the \c "T". The other elements are years, days, hours, and seconds. Fractional values are accepted as well, but these values are always converted to an integer value in the time component with higher precision (i.e. fractional seconds are converted to microseconds, fractional microseconds are ignored), and additionally the values may be negative.

    @note
    - Standard <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> relative date/time formats only allows for the last component to have a fractional value.
    - Fractional years are converted to days assuming 365 days in a year
    - Fractional months are converted to days assuming an average 30 days in a month

    Here are some examples (using qore's -X command-line option to evaluate and expression and print out the result):
    @code{.py}
prompt% qore -X 'P1Y3MT4S'
<time: 1 year 3 months 4 seconds>
prompt% qore -X 'PT4M551u'
<time: 4 minutes 551 microseconds>
prompt% qore -X 'P3DT21H'
<time: 3 days 21 hours>
prompt% qore -X 'PT19.1S'
<time: 19 seconds 100 milliseconds>
    @endcode

    @note the \c "u" charater indicating microseconds is a deprecated %Qore-specific extension to <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>; use fractional seconds instead

    @subsubsection long_reldates Long Relative Time Format
    The second <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a>-based format for specifing complex durations with multiple time units has the following syntax:
    - \c PYYYY-MM-DDTHH:mm:SS
    .
    This format is more limited than the first format, in that all values must be non-negative, and furthermore, all values must be present (although they may be zero).\n\n
    Here are some examples of the second format (equivalent to the first examples):
    @code{.py}
prompt% qore -X 'P0001-03-00T00:00:04'
<time: 1 year 3 months 4 seconds>
prompt% qore -X 'P0000-00-00T00:04:00.000551'
<time: 4 minutes 551 microseconds>
prompt% qore -X 'P0000-00-03T21:00:00'
<time: 3 days 21 hours>
    @endcode
    @see @ref date_type, @ref softdate_type

    @subsubsection reldate_comparisons Relative Date/Time Comparisons

    Comparisons with two relative date/time values are made with normalized representations of each component of the date/time value.  Because the actual value of a relative date/time value only makes sense when used with an @ref absolute_dates "absolute date value" (ex: adding \c 1M to an absolute date value will result in a different number of days being added depending on the month and day of the @ref absolute_dates "absolute date value" operand), comparisons of relative date/time values with mixed day, month, and year components must be based on approximations.   When mixing day, month, and year components, the following approximations are used:
    - one day is treated as equivalent to 24 hours (\c 1D == \c 24h)
    - one month is treated as equivalent to 31 days (\c 1M == \c 31D)
    - 365 days are treated as equivalent to one year (\c 365D == \c 1Y)

    These assumptions try to make sense of expressions like: @verbatim 45D > 1M @endverbatim for example.  Month lengths can range from 28 to 31 days, therefore while the expression: @verbatim 30D < 1M @endverbatim will be evaluated as @ref True "True", when adding \c 30D to an @ref absolute_dates "absolute date value", the result could be less than adding \c 1M (for example, when the operand is an @ref absolute_dates "absolute date" in February).

    <hr>
    @section binary Binary

    @par Description:
    The binary data type is used to hold binary arbitrary binary data. Internally it is represented by a pointer to a memory location for the data and a size indicator.\n\n
    Binary literal values are given in between angle brackets as an even series of hexadecimal digits:\n
    @code{.py}
binary b = <651144fe3310b5cc84>;
b += <abde77>;
# b now contains <651144fe3310b5cc84abde77>
    @endcode \n
    Binary data can be concatenated with the + and += operators and manipulated with the @ref splice "splice" and @ref extract "extract" operators.\n\n
    This data can be manipulated by being written and read from @ref Qore::File, @ref Qore::Socket, @ref Qore::SQL::Datasource, @ref Qore::SQL::DatasourcePool, or @ref Qore::SQL::SQLStatement objects, or converted and parsed to/from base64 encoded strings using the makeBase64String() and parseBase64String() functions, or compressed and decompressed using the compress(), gzip(), bzip2(), etc. functions, and processed by most cryptographic funtions, among others.\n\n
    Binary objects can be read from a @ref Qore::File object using the Qore::File::readBinary() method and can be written using the Qore::File::write() method. Please see the @ref Qore::File class for more information.\n\n
    Binary objects can be read from a @ref Qore::Socket object using the Qore::Socket::recvBinary() method and can be written using the Qore::Socket::send() method. Please see the @ref Qore::Socket class for more information.\n\n
    The @ref Qore::SQL::Datasource, @ref Qore::SQL::DatasourcePool, and @ref Qore::SQL::SQLStatement classes can also be used to read and write binary objects as BLOBs.\n\n
    Note that this is not an exhaustive list; see the function and class library documentation for more examples.

    @par Immediate Value Example:
    <tt>\<0feba023ffdca6291\></tt>

    @par Pseudo Class for Type Binary:
    @ref Qore::zzz8binaryzzz9

    @par Type Code:
    @ref Qore::NT_BINARY

    @par Type Name:
    \c "binary"

    @anchor binary_slicing
    @par Binary slicing:
    Binary objects can be "sliced" by dereferencing them using the @ref list_element_operator "[] operator" with a range or a list, as in the following examples:\n
    @code{.py}
binary bin = <beadface>;

# Creates a binary slice with the first two bytes of the original binary object
binary bin1a = bin[0..1];
binary bin1b = bin[0,1];
binary bin1c = bin[..1];
printf("binary 1a: %s\n", bin1a.toHex());
printf("binary 1b: %s\n", bin1b.toHex());
printf("binary 1c: %s\n", bin1c.toHex());

# Creates a binary slice with the last two bytes of the original binary object in reverse order
binary bin2a = bin[3..2];
binary bin2b = bin[3,2];
printf("binary 2a: %s\n", bin2a.toHex());
printf("binary 2b: %s\n", bin2b.toHex());

# Creates a binary slice with different bytes of the original binary object
binary bin3 = bin[3,2..1,0];
printf("binary 3: %s\n", bin3.toHex());

# -------------------------
# the output is as follows:
binary 1a: bead
binary 1b: bead
binary 1c: bead
binary 2a: cefa
binary 2b: cefa
binary 3: cefaadbe
    @endcode \n

    When making a binary slice with a list of byte offsets and referring to a byte offset that does not exist,
    no bytes are added to the output binary slice; these references are ignored.

    @see
    - @ref binary_type
    - @ref hexbinary_type
    - @ref base64binary_type
    - @ref softbinary_type

    <hr>
    @section null NULL

    @par Description:
    This data type represents an SQL \c NULL value and can only be accessed directly as an immediate value with the
    keyword @ref NULL. Note that @ref NULL is not equivalent to @ref NOTHING.

    @par Immediate Value Example:
    @ref NULL

    @par Pseudo Class for Type Null:
    @ref Qore::zzz8valuezzz9

    @par Type Code:
    @ref Qore::NT_NULL

    @par Type Name:
    \c "NULL"

    @see
    - @ref Qore::SQL::Datasource
    - @ref Qore::SQL::DatasourcePool
    - @ref Qore::SQL::SQLStatement
    - @ref dbi_functions

    @subsection NULL NULL

    The keyword \c \b NULL stands for the SQL NULL value.

    <hr>
    @section nothing NOTHING

    @par Description:
    This special data type represents no value and can only be accessed directly as an immediate value with the
    keyword @ref NOTHING.  Note that @ref NOTHING is not equivalent to @ref NULL .\n

    @note The exists operator will return @ref False "False" when given @ref NOTHING as an argument; for example: @verbatim prompt% qore -X 'exists NOTHING'
False@endverbatim

    @par Immediate Value Example:
    @ref NOTHING

    @par Pseudo Class for Type Nothing:
    @ref Qore::zzz8valuezzz9

    @par Type Code:
    @ref Qore::NT_NOTHING

    @par Type Name:
    \c "nothing"

    @subsection NOTHING NOTHING

    The keyword \c \b NOTHING represents no value.

    @section conversions Data Conversions

    Boolean, string, integer, date, floating point, and arbitrary-percision numeric data types can be freely converted from one type to the other, although data loss is possible depending on the conversion (particularly when converting to the boolan type as only two possible values are supported).

    The special types @ref null and @ref nothing are not equivalent and are generally not automatically converted to or from any other type.

    When date types are converted from strings, any of the following formats can be used: \c "YYYYMMDDHHmmSS[.us][Z|+-HH[:MM[:SS]]]", \c "YYYY-MM-DD HH:mm:SS.us", \c "YYYY-MM-DDTHH:mm:SS", \c "YYYY-MM-DDTHH:mm:SS[.us][Z|+-HH[:MM[:SS]]]", and most reasonable combinations thereof. If the time zone component is missing, then the local time zone will be assumed (see @ref time_zones).

    When dates are converted to and from integer, floating-point, and arbitrary-percision numeric values, the a 64-bit second offset from January 1, 1970 in the local time zone is used for the conversion. For example @code{.py} int(2006-01-01)@endcode gives \c 1136073600 (regardless of the local time zone the date is in). This is for backwards-compatibility with %Qore before @ref time_zones "time zone support" was available; to get the second offset of a date from \c 1970-01-01Z (i.e. the true epoch offset), call get_epoch_seconds() instead.

    When an expression requires a certain data type and the source data type cannot be converted to the desired data type, the default value for the desired data type will be used. The default values are given in @ref basic_data_types.
*/
