# File condition.hpp

↰ Parent directory (`cif++`)

## Definition (`cif++/condition.hpp`)

- Program Listing for File condition.hpp

## Detailed Description

This file contains code to create conditions: object encapsulating a query you can use to find rows in a Class category

Conditions are created as standard C++ expressions. That means you can use the standard comparison operators to compare item contents with a value and boolean operators to chain everything together.

To create a query that simply compares one item with one value:

:ref:`exhale_class_classcif_1_1condition`c=:ref:`exhale_struct_structcif_1_1key`(“id”)==1;

That will find rows where the ID item contains the number 1. If using Struct key is a bit too much typing, you can also write:

usingnamespacecif::literals;

:ref:`exhale_class_classcif_1_1condition`c2=”id”_key==1;

Now if you want both ID = 1 and ID = 2 in the result:

autoc3=”id”_key==1or”id”_key==2;

There are some special values you can use. To find rows with item that do not have a value:

autoc4=”type”_key==:ref:exhale_variable_namespacecif_1a6dacacf91cee6e2c246a2334f0fbd607;

Of if it should not be NULL:

autoc5=”type”_key!=:ref:exhale_variable_namespacecif_1a6dacacf91cee6e2c246a2334f0fbd607;

There’s even a way to find all records:

autoc6=:ref:exhale_function_namespacecif_1a39ae1da888a5c8a6ee7f1438b78b7734;

And when you want to search for any item containing the value ‘foo’:

autoc7=:ref:`exhale_variable_namespacecif_1a9347107ebb4ef72dca122c3285453c4f`==”foo”;

All these conditions can be chained together again:

autoc8=std::move(c3)andstd::move(c5);

## Includes

- `cassert`

- `cif++/item.hpp` (File item.hpp)

- `cif++/row.hpp` (File row.hpp)

- `cif++/text.hpp` (File text.hpp)

- `cstddef`

- `cstdint`

- `format` (File format.hpp)

- `functional`

- `iostream`

- `optional`

- `regex`

- `string`

- `string_view`

- `type_traits`

- `typeinfo`

- `utility`

- `vector`

## Included By

- File category.hpp

- File cif++.hpp

- File iterator.hpp

## Namespaces

- Namespace cif

- Namespace cif::detail

- Namespace cif::literals

## Classes

- Struct empty_type

- Struct key

- Class condition

## Functions

- Function cif::all

- Function cif::get_category_fields

- Function cif::get_category_items

- Function cif::get_item_ix

- Function cif::is_item_type_uchar

- Function cif::literals::operator””_key

- Function cif::operator!

- Template Function cif::operator!=(const key&, const std::optional<T>&)

- Function cif::operator!=(const key&, const empty_type&)

- Function cif::operator!=(const key&, const item_value&)

- Function cif::operator&&

- Function cif::operator<(const key&, std::string_view)

- Template Function cif::operator<(const key&, const T&)

- Function cif::operator<=(const key&, std::string_view)

- Template Function cif::operator<=(const key&, const T&)

- Template Function cif::operator==(const any_type&, const T&)

- Function cif::operator==(const key&, const std::regex&)

- Function cif::operator==(const any_type&, const std::regex&)

- Function cif::operator==(const key&, const empty_type&)

- Function cif::operator==(const key&, const item_value&)

- Template Function cif::operator==(const key&, const std::optional<T>&)

- Template Function cif::operator>(const key&, const T&)

- Function cif::operator>(const key&, std::string_view)

- Template Function cif::operator>=(const key&, const T&)

- Function cif::operator>=(const key&, std::string_view)

- Function cif::operator||

## Variables

- Variable cif::any

- Variable cif::null