The Product represents a single product with a unique numerical identifier, human-readable name, and integral non-negative quantity.
More...
#include <Product.h>
The Product represents a single product with a unique numerical identifier, human-readable name, and integral non-negative quantity.
Definition at line 21 of file Product.c.
◆ product_create()
| struct Product * product_create |
( |
unsigned int |
id, |
|
|
const char * |
name, |
|
|
unsigned int |
quantity |
|
) |
| |
Create a new Product with the given initial properties.
- Parameters
-
| id | The numerical identifier of the Product. |
| name | A human-readable name of the Product. |
| quantity | The initial quantity of the Product in stock. |
- Returns
- The dynamically allocated Product with the initial properties set.
Definition at line 28 of file Product.c.
◆ product_delete()
| void product_delete |
( |
struct Product ** |
this | ) |
|
Delete the given dynamically initialised Product and reset its pointer.
- Parameters
-
Definition at line 53 of file Product.c.
◆ product_file_serialise()
| int product_file_serialise |
( |
const struct Product * |
this, |
|
|
FILE * |
buffer |
|
) |
| |
Serialise the given Product in the stock file format to the given buffer.
- Parameters
-
| this | The Product to serialise. |
| buffer | The destination file buffer for the serialised Product information. |
- Returns
- The number of bytes written, or negative if an error occurred. In the latter case,
errno is set.
Definition at line 64 of file Product.c.
◆ product_modify_quantity()
| bool product_modify_quantity |
( |
struct Product * |
this, |
|
|
int |
modifier |
|
) |
| |
Attempt to modify the quantity of the given Product.
- Parameters
-
| this | The Product to modify. |
| modifier | The amount by which the quantity of the given Product should be incremented or decremented. |
- Returns
- Was the modification successful? Modification will fail if and only if the quantity would go negative.
Definition at line 69 of file Product.c.
◆ product_ptr_compare()
| int product_ptr_compare |
( |
const void * |
product_lhs, |
|
|
const void * |
product_rhs |
|
) |
| |
Compare the Product items pointed to by the given LHS and RHS according to stock levels.
- Parameters
-
- Returns
-
-1 if the stock level of the LHS operand is strictly less than the stock level of the RHS operand;
-
0 if the stock level of the LHS operand is equal to the stock level of the RHS operand; or
-
1 if the stock level of the LHS operand is strictly greater than the stock level of the RHS operand.
Definition at line 78 of file Product.c.
◆ product_report_serialise()
| int product_report_serialise |
( |
const struct Product * |
this, |
|
|
FILE * |
buffer |
|
) |
| |
Serialise the given Product in the report format to the given buffer.
- Parameters
-
| this | The Product to serialise. |
| buffer | The destination file buffer for the serialised Product information. |
- Returns
- The number of bytes written, or negative if an error occurred. In the latter case,
errno is set.
Definition at line 59 of file Product.c.
◆ id
◆ name
NULL-terminated human-readable name of the Product.
Definition at line 25 of file Product.c.
◆ quantity
| unsigned int Product::quantity |
The documentation for this struct was generated from the following files: