CONZEPT 16 C++ API
C16::Procedure Class Reference

Procedure buffer to operate on procedures of a database. More...

#include "C16/Procedure.hpp"

Inheritance diagram for C16::Procedure:
C16::Text

Detailed Description

Procedure buffer to operate on procedures of a database.

Examples

Iteration

#include "C16/Library.hpp"
using namespace C16;
void procedures_iterate(Database& database)
{
Procedure procedure(database);
for
(
Result result = procedure.read(Place::FIRST);
result != Result::NO_KEY;
result = procedure.read(Place::NEXT)
)
{
// Permissions insufficient
if (result == Result::NO_RIGHTS)
continue;
...
}
}

Execution

#include "C16/Library.hpp"
using namespace C16;
void procedure_execute(const Procedure& procedure)
{
// Executes the main function of the procedure and
// passes no arguments.
procedure.execute("main");
// Executes the main function of the procedure,
// passes no arguments and
// gets the return value (of type "alpha").
Value::Alpha return_alpha = procedure.execute("main");
// Executes the function "f" of the procedure and
// passes literals as arguments (of type "alpha" and "int") by value.
procedure.execute("f", "abc", 123);
// Executes the function "f" of the procedure,
// passes literals as arguments (of type "alpha" and "int") by value and
// gets the return value (of type "int").
Value::Int return_int = procedure.execute("f", "abc", 123);
{
// Declares and defines constant arguments.
const Value::Alpha argument_alpha = "abc";
const Value::Int argument_int = 123;
// Executes the function "f" of the procedure and
// passes variables as arguments by value.
procedure.execute("f", argument_alpha, argument_int);
}
{
// Declares and defines non-constant arguments.
Value::Alpha argument_alpha = "abc";
Value::Int argument_int = 123;
// Executes the function "f" of the procedure and
// passes variables as arguments by reference.
procedure.execute("f", argument_alpha, argument_int);
}
}

Classes

class  Compilation
 Compilation of a procedure. More...
 
class  Execution
 Execution of a procedure. More...
 

Public Member Functions

 Procedure (Database &database)
 Constructs a procedure buffer. More...
 
Execution execution (const std::string &function_name) const
 Gets an execution of a function of the procedure. More...
 
template<typename ... Arguments>
Variant execute (const std::string &function_name, Arguments &&... arguments) const
 Executes a function of the procedure. More...
 
Compilation::Error compile () const
 Compiles the procedure and gets its error. More...
 
Compilation::Result compile_result (Compilation::ErrorLanguage error_language=Compilation::ErrorLanguage::ENGLISH_US) const
 Compiles the procedure and gets its result. More...
 
- Public Member Functions inherited from C16::Text
 Text (Database &database)
 Constructs a text buffer. More...
 
Databasedatabase () const
 Gets the database of the text buffer. More...
 
bool loaded () const
 Gets if a text is loaded into the text buffer. More...
 
const std::string & name () const
 Gets the name of the loaded text. More...
 
long int size () const
 Gets the size of the loaded text in units of bytes. More...
 
long int line_count () const
 Gets the line count of the loaded text. More...
 
const Value::Datecreated_date () const
 Gets the date of the creation of the loaded text. More...
 
const Value::Timecreated_time () const
 Gets the time of the creation of the loaded text. More...
 
const std::string & created_user () const
 Gets the user who created the loaded text. More...
 
const Value::Datemodified_date () const
 Gets the date of the last modification of the loaded text. More...
 
const Value::Timemodified_time () const
 Gets the time of the last modification of the loaded text. More...
 
const std::string & modified_user () const
 Gets the user who last modified the loaded text. More...
 
const std::string & group () const
 Gets the group of the loaded text. More...
 
void group_set (const std::string &group)
 Sets the group of the loaded text. More...
 
int right_read () const
 Gets the right required by a user to read the loaded text. More...
 
void right_read_set (int right_read)
 Sets the right required by a user to read the loaded text. More...
 
int right_write () const
 Gets the right required by a user to write the loaded text. More...
 
void right_write_set (int right_write)
 Sets the right required by a user to write the loaded text. More...
 
bool personal () const
 Gets if the loaded text is private. More...
 
void personal_set (bool personal)
 Sets if the loaded text is private. More...
 
const std::string & personal_user () const
 Gets the user who set the loaded text to private. More...
 
bool encrypted () const
 Gets if the loaded text is encrypted. More...
 
void encrypted_set (bool encrypted)
 Sets if the loaded text is encrypted. More...
 
std::string content (LineBreak line_break=LineBreak::LF) const
 Gets the content of the loaded text. More...
 
Result content_set (const std::string &content, LineBreak line_break=LineBreak::LF)
 Sets the content of the loaded text. More...
 
Result read (const std::string &name, Place place=Place::KEY, Locking locking=Locking::NONE)
 Reads a text by means of a reference name and a place into the text buffer. More...
 
Result read (Place place, Locking locking=Locking::NONE)
 Reads a text by means of a place into the text buffer. More...
 
Result reload (Locking locking=Locking::NONE)
 Reloads the loaded text. More...
 
void unload ()
 Unloads the loaded text. More...
 
Result write (Locking locking=Locking::NONE)
 Writes the loaded text. More...
 
Result create (const std::string &name, Locking locking=Locking::NONE)
 Creates and loads a text. More...
 
Result erase () const
 Deletes the loaded text. More...
 
Result rename (const std::string &name)
 Renames the loaded text. More...
 
Result copy (const std::string &name) const
 Copies the loaded text. More...
 

Additional Inherited Members

- Public Types inherited from C16::Text
enum  LineBreak { LineBreak::NUL, LineBreak::CR, LineBreak::LF, LineBreak::CR_LF }
 Line break. More...
 
- Static Public Attributes inherited from C16::Text
static const int NAME_LENGTH_LIMIT = 20
 Name length limit. More...
 
static const int GROUP_LENGTH_LIMIT = 20
 Group length limit. More...
 

Constructor & Destructor Documentation

◆ Procedure()

C16::Procedure::Procedure ( Database database)
explicit

Constructs a procedure buffer.

Parameters
databaseDatabase the procedure buffer relates to

Member Function Documentation

◆ execution()

Execution C16::Procedure::execution ( const std::string &  function_name) const

Gets an execution of a function of the procedure.

Parameters
function_nameName of the function
See also
Procedures::execution

Referenced by execute().

◆ execute()

template<typename ... Arguments>
Variant C16::Procedure::execute ( const std::string &  function_name,
Arguments &&...  arguments 
) const
inline

Executes a function of the procedure.

Parameters
function_nameName of the function
argumentsArguments
Returns
Return value of the function
Exceptions
ExceptionProcedure execution exception occurred.
See also
Examples

References C16::Procedure::Execution::arguments_add(), C16::Procedure::Execution::execute_error_throw(), and execution().

◆ compile()

Compilation::Error C16::Procedure::compile ( ) const

Compiles the procedure and gets its error.

Returns
Error
Exceptions
Exception::InvalidityName invalid.

◆ compile_result()

Compilation::Result C16::Procedure::compile_result ( Compilation::ErrorLanguage  error_language = Compilation::ErrorLanguage::ENGLISH_US) const

Compiles the procedure and gets its result.

Parameters
error_languageLanguage of the error text
Returns
Result
Exceptions
Exception::InvalidityName invalid.
No procedure loaded.
C16::Value::Int
std::int32_t Int
Integer number (signed, 32 bits).
Definition: Native.hpp:24
C16::Result::NO_RIGHTS
@ NO_RIGHTS
Permissions insufficient.
C16::Procedure
Procedure buffer to operate on procedures of a database.
Definition: Procedure.hpp:108
C16::Place::NEXT
@ NEXT
Operate on the next entity.
C16::Place::FIRST
@ FIRST
Operate on the first entity.
C16::Text::database
Database & database() const
Gets the database of the text buffer.
Library.hpp
CONZEPT 16 C++ API.
C16::Result::NO_KEY
@ NO_KEY
Entity inexistent but following entity existent.
C16::Value::Alpha
std::string Alpha
String.
Definition: Native.hpp:16
C16::Procedure::execute
Variant execute(const std::string &function_name, Arguments &&... arguments) const
Executes a function of the procedure.
Definition: Procedure.hpp:509
C16::Database
Database hosted by a server.
Definition: Database.hpp:38
C16::Result
Result
Result of an operation related to a database entity.
Definition: Result.hpp:12
C16
Namespace.
Definition: Array.hpp:6