mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Expose is_* methods on tasks.
This commit is contained in:
parent
7c27f116ad
commit
88333ac785
5 changed files with 53 additions and 3 deletions
|
@ -99,6 +99,30 @@ std::string tc::Task::get_description () const
|
||||||
return tc2string(desc);
|
return tc2string(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool tc::Task::is_waiting () const
|
||||||
|
{
|
||||||
|
return tc_task_is_waiting (&*inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool tc::Task::is_active () const
|
||||||
|
{
|
||||||
|
return tc_task_is_active (&*inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool tc::Task::is_blocked () const
|
||||||
|
{
|
||||||
|
return tc_task_is_blocked (&*inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool tc::Task::is_blocking () const
|
||||||
|
{
|
||||||
|
return tc_task_is_blocking (&*inner);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string tc::Task::task_error () const {
|
std::string tc::Task::task_error () const {
|
||||||
TCString error = tc_task_error (&*inner);
|
TCString error = tc_task_error (&*inner);
|
||||||
|
|
|
@ -79,8 +79,10 @@ namespace tc {
|
||||||
// TODO: time_t tc_task_get_entry(struct TCTask *task);
|
// TODO: time_t tc_task_get_entry(struct TCTask *task);
|
||||||
// TODO: time_t tc_task_get_wait(struct TCTask *task);
|
// TODO: time_t tc_task_get_wait(struct TCTask *task);
|
||||||
// TODO: time_t tc_task_get_modified(struct TCTask *task);
|
// TODO: time_t tc_task_get_modified(struct TCTask *task);
|
||||||
// TODO: bool tc_task_is_waiting(struct TCTask *task);
|
bool is_waiting() const;
|
||||||
// TODO: bool tc_task_is_active(struct TCTask *task);
|
bool is_active() const;
|
||||||
|
bool is_blocked() const;
|
||||||
|
bool is_blocking() const;
|
||||||
// TODO: bool tc_task_has_tag(struct TCTask *task, struct TCString tag);
|
// TODO: bool tc_task_has_tag(struct TCTask *task, struct TCString tag);
|
||||||
// TODO: struct TCStringList tc_task_get_tags(struct TCTask *task);
|
// TODO: struct TCStringList tc_task_get_tags(struct TCTask *task);
|
||||||
// TODO: struct TCAnnotationList tc_task_get_annotations(struct TCTask *task);
|
// TODO: struct TCAnnotationList tc_task_get_annotations(struct TCTask *task);
|
||||||
|
|
|
@ -356,6 +356,18 @@ pub unsafe extern "C" fn tc_task_is_active(task: *mut TCTask) -> bool {
|
||||||
wrap(task, |task| task.is_active())
|
wrap(task, |task| task.is_active())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a task is blocked (depends on at least one other task).
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn tc_task_is_blocked(task: *mut TCTask) -> bool {
|
||||||
|
wrap(task, |task| task.is_blocked())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a task is blocking (at least one other task depends on it).
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn tc_task_is_blocking(task: *mut TCTask) -> bool {
|
||||||
|
wrap(task, |task| task.is_blocking())
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if a task has the given tag. If the tag is invalid, this function will return false, as
|
/// Check if a task has the given tag. If the tag is invalid, this function will return false, as
|
||||||
/// that (invalid) tag is not present. No error will be reported via `tc_task_error`.
|
/// that (invalid) tag is not present. No error will be reported via `tc_task_error`.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
|
@ -789,6 +789,16 @@ bool tc_task_is_waiting(struct TCTask *task);
|
||||||
*/
|
*/
|
||||||
bool tc_task_is_active(struct TCTask *task);
|
bool tc_task_is_active(struct TCTask *task);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a task is blocked (depends on at least one other task).
|
||||||
|
*/
|
||||||
|
bool tc_task_is_blocked(struct TCTask *task);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a task is blocking (at least one other task depends on it).
|
||||||
|
*/
|
||||||
|
bool tc_task_is_blocking(struct TCTask *task);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a task has the given tag. If the tag is invalid, this function will return false, as
|
* Check if a task has the given tag. If the tag is invalid, this function will return false, as
|
||||||
* that (invalid) tag is not present. No error will be reported via `tc_task_error`.
|
* that (invalid) tag is not present. No error will be reported via `tc_task_error`.
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int, char**)
|
int main (int, char**)
|
||||||
{
|
{
|
||||||
UnitTest t (21);
|
UnitTest t (23);
|
||||||
|
|
||||||
// This function contains unit tests for the various bits of the wrappers for
|
// This function contains unit tests for the various bits of the wrappers for
|
||||||
// taskchampion-lib (that is, for `src/tc/*.cpp`).
|
// taskchampion-lib (that is, for `src/tc/*.cpp`).
|
||||||
|
@ -92,6 +92,8 @@ int main (int, char**)
|
||||||
auto map = task.get_taskmap ();
|
auto map = task.get_taskmap ();
|
||||||
t.is (map["description"], "a test", "task description in taskmap");
|
t.is (map["description"], "a test", "task description in taskmap");
|
||||||
t.is (task.get_description(), "a test", "returned task has correct description");
|
t.is (task.get_description(), "a test", "returned task has correct description");
|
||||||
|
t.is (task.is_waiting(), false, "task is not waiting");
|
||||||
|
t.is (task.is_active(), false, "task is not active");
|
||||||
|
|
||||||
//// WorkingSet
|
//// WorkingSet
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue