Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Elektra Highlevel API #1605

Closed
wants to merge 143 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
6d9734b
Elektra API interface, elektraGetString and elektraGetLongLong implem…
domhof Mar 13, 2017
75796e7
Free error and elektra structs
domhof Mar 13, 2017
e2301a4
Fix code style
domhof Mar 13, 2017
06c16e0
Move high level API to separate module
domhof Mar 14, 2017
fc0ee68
Hide implementation of _Elektra and _ElektraError
domhof Mar 14, 2017
37cb44b
Include elektra.h
domhof Mar 14, 2017
377084c
Adapt template to procude camelcase functions
domhof Mar 15, 2017
64a82de
Replace _ from key names with camelcase
domhof Mar 15, 2017
56560e9
Prefix function names with elektra
domhof Mar 15, 2017
af3bf15
Implement High Level API functions
domhof Mar 16, 2017
c0db93d
Do not keyDel the key returned from ksLookup
domhof Apr 9, 2017
dad3a2a
Do not copy string in elektraGetString
domhof Apr 9, 2017
b7adcdd
Add new line at the end in CMakeLists.txt
domhof Apr 9, 2017
cb3ac76
Add c_elektra.py to temporarily keep alternative version
domhof Apr 9, 2017
6475380
Reset c.py
domhof Apr 9, 2017
e9b12d2
Gitignore CLion project files
domhof Apr 9, 2017
fb6b904
Add test_elektra
domhof Apr 9, 2017
15a4e5a
Fix keyNew argument
domhof Apr 9, 2017
c1bea53
Add more debug output
domhof Apr 11, 2017
d25ac4c
Only consider 1 as boolean true
domhof Apr 11, 2017
e7d3bf2
Add error parameter to elektraOpen, add elektraErrorDel
domhof Apr 11, 2017
2ad5cee
Remove elektraClearError, implement elektraErrorDel
domhof Apr 11, 2017
02c7435
Remove NULL pointer check
domhof Apr 11, 2017
aebf102
Remove error from Elektra struct
domhof Apr 11, 2017
7dac444
Implement elektraErrorCreate, remove old error functions
domhof Apr 11, 2017
30877c1
Extract ElektraError
domhof Apr 11, 2017
81285fe
Implement error accessors
domhof Apr 11, 2017
c41a856
Add NULL check for kdbOpen
domhof Apr 11, 2017
bad63bf
Add result check to kdbGet
domhof Apr 11, 2017
e2ef642
Abort if key doesn't exist
domhof Apr 11, 2017
6b770b6
Check key type metadata in getters
domhof Apr 11, 2017
10e1540
Rename elektraErrorDel to elektraErrorFree
domhof Apr 11, 2017
4439926
Fix elektraErrorCreate signature
domhof Apr 12, 2017
2671a6e
Move elektra_error.c into highlevel, add header to CMakeLists.txt
domhof Apr 12, 2017
0abf454
Add new line to elektra_error.h
domhof Apr 12, 2017
1bdfe36
Implement ElektraError, test getters
domhof Apr 18, 2017
a3e7388
tests/ctest/test_elektra.c -> tests/ctest/test_highlevel.c
domhof Apr 18, 2017
3d50783
Fix code format
domhof Apr 18, 2017
1cac58a
Remove removeMetaData, fix test target name
domhof Apr 18, 2017
5e8c5ae
Replace error type 'normal' with 'error'
domhof Apr 24, 2017
167fff1
Add temporary enum identifiers to errors
domhof Apr 24, 2017
c6da5bc
Remove empty line causing compile error
domhof Apr 28, 2017
61f6f04
Remove elektraprivate.h
domhof Apr 28, 2017
b2ae18b
Generate error code enum
domhof Apr 28, 2017
f3e29b7
Use elektraFreeError in test
domhof Apr 28, 2017
8845fdf
Add array functions to header and implement elektraGetStringArrayElement
domhof Apr 28, 2017
f313931
Refactor elektra.c
domhof Apr 28, 2017
0bef136
Add doc to elektraGetStringArrayElement
domhof Apr 28, 2017
4d0c7e6
Introduce KDBType
domhof Apr 28, 2017
e1bd763
Implement array functions
domhof Apr 28, 2017
af327f1
Free lookupKey in elektraClose
domhof Apr 28, 2017
1d1a539
Adapt code style
domhof Apr 28, 2017
b7bdd0c
Move docs to header
domhof Apr 28, 2017
04837ba
Implement elektraArraySize
domhof Apr 28, 2017
d6fe7f3
Implement array tests
domhof Apr 28, 2017
95b65ae
Update high_level_api.md
domhof Apr 28, 2017
66043b7
Remove rebasing leftover from error specification
domhof Apr 28, 2017
3392f4e
Use lookup function in getValueAsString
domhof May 1, 2017
5053bed
Implement setters
domhof May 1, 2017
28cb6a5
Implement array setters
domhof May 1, 2017
c207b49
Add header doc
domhof May 1, 2017
60d6e9d
Add debug output
domhof May 1, 2017
9ca3df6
Add elektra_error_codes.h
domhof May 1, 2017
fef8fde
Disable logs
domhof May 2, 2017
7476a46
Create README.md
domhof May 3, 2017
60fd5d9
Update README.md
domhof May 3, 2017
9aa510e
Update README.md
domhof May 3, 2017
af5da78
Elektra High-Level API Tutorial
domhof May 3, 2017
37fc246
Update README.md
domhof May 3, 2017
874347b
Update README.md
domhof May 3, 2017
3105b93
Update README.md
domhof May 3, 2017
5f96a43
Update README.md
domhof May 3, 2017
aae56d1
Update README.md
domhof May 3, 2017
93e46ef
Rename elektraErrorFree to elektraErrorReset and set error to NULL
domhof May 3, 2017
b2c4f1f
Update README.md
domhof May 3, 2017
9814c6b
Add highlevel to ElektraConfig.cmake.in and elektra.pc.in
domhof May 7, 2017
9beb3dd
Update .gitignore
domhof May 7, 2017
b832acd
Re-add missing error
domhof May 7, 2017
6a9e28d
Add KEY_END
domhof May 7, 2017
96c7016
Reenable logs
domhof May 7, 2017
cdad428
Apply scripts/reformat-source
domhof May 7, 2017
e3daae8
In setters return error if non-conlflicting
domhof May 7, 2017
bb380a0
Update README.md
domhof May 7, 2017
c67cd13
Update README.md
domhof May 7, 2017
9ebc60b
Adapt tests
domhof May 7, 2017
2156e8f
Apply reformat-source
domhof May 7, 2017
4c36ca6
Apply reformat-source with clang-format 3.8
domhof May 8, 2017
0fc90ec
Update README.md
domhof May 8, 2017
8f85790
Update README.md
domhof May 8, 2017
14d499b
Update README.md
domhof May 8, 2017
db984d8
Update README.md
domhof May 8, 2017
5cd238d
Update README.md
domhof May 8, 2017
6ca74fb
Update README.md
domhof May 8, 2017
0df5652
Refactor elektra.c, allow new keys
domhof May 8, 2017
0bc6e89
Add clang pragmas
domhof May 8, 2017
578cb78
Add defaults parameter and tests
domhof May 8, 2017
7c0efe5
Put docs in .c and group as High-level API
domhof May 8, 2017
e1585a4
Use lower case key names to adhere to convention
domhof May 9, 2017
4d973ff
Require C11 for test_highlevel
domhof May 11, 2017
a78710a
NULL check in elektraErrorReset
domhof May 11, 2017
c89f976
Implement generic accessors
domhof May 15, 2017
4f6c3f2
Add generic tests
domhof May 15, 2017
7024d9d
Generate defines
domhof May 16, 2017
20cb96e
Add setters and getters
domhof May 16, 2017
a87ffd5
Remove old code
domhof May 16, 2017
4b7c69a
Apply reformat-source
domhof May 16, 2017
03115b9
Add array defines and docs
domhof May 19, 2017
088aeb6
Update README.md
domhof May 19, 2017
401fc29
Update README.md
domhof May 19, 2017
b11d4ec
Apply reformat-source
domhof May 19, 2017
96a62f1
Update README.md
domhof May 19, 2017
33baf51
Simplify type tag generation code
domhof May 31, 2017
236b5b7
codegen: Favor gen/type over type
domhof Jun 1, 2017
4415089
codegen: Add stringkey entry
domhof Jun 1, 2017
5988c8d
highlevel: Fix macro errors
domhof Jul 18, 2017
98cf6e5
codegen: Generate generic code for enums
domhof Jul 19, 2017
dda06c5
codegen: Move declarations part to elektra header
domhof Jul 19, 2017
1687666
codegen: Generate typed tag and string setters/getters
domhof Jul 19, 2017
1e91099
codegen: Add elektra_generic.h to CMakeLists.txt
domhof Jul 23, 2017
d0860e6
highlevel: Prefix defaults with application
domhof Jul 30, 2017
ec37a47
highlevel: Init default KeySet with number of parameters
domhof Jul 30, 2017
8fff9c0
codegen: Add defines for enum type and conversions
domhof Jul 30, 2017
a7077c9
highlevel: Prefix internals with __
domhof Jul 30, 2017
86d13fc
highlevel: Eliminate elektraSetByString
domhof Jul 31, 2017
96f2bbd
codegen: Remove generated files
domhof Aug 2, 2017
e2f9f95
codegen: Remove trailing whitespace
domhof Aug 9, 2017
0464403
codegen: Add newline after enum declaration
domhof Aug 9, 2017
086690e
codegen: Extend key normalization to remove trailing / and #
domhof Aug 9, 2017
c5fe53d
codegen: Fix default string values
domhof Aug 19, 2017
cc1cb62
highlevel: Eliminate elektraSetArrayElementByString
domhof Aug 20, 2017
3dd8f14
highlevel: Use long as error code
domhof Aug 20, 2017
cdc9200
highlevel: Remove enums from error specification
domhof Aug 20, 2017
3b56cf8
Apply reformat-source
domhof Aug 20, 2017
6be6f55
codegen: Require default or required property for all keys
domhof Aug 27, 2017
37d0621
codegen: Improve enum support
domhof Sep 5, 2017
77da794
highlevel: Update function names
domhof Sep 5, 2017
79863fb
highlevel: Array index before value
domhof Sep 11, 2017
e52104c
codegen: Always require default
domhof Sep 13, 2017
6fca9bd
Apply reformat-source
domhof Sep 13, 2017
5872dcd
highlevel: Expose KDB_TYPE
domhof Sep 13, 2017
ad326a0
highlevel: Fix long_double
domhof Sep 13, 2017
4fc30e7
highlevel: Fix long_double tests
domhof Sep 13, 2017
5aec70f
Merge branch 'master' into elektra_api
domhof Nov 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ nbproject/
#ignore macOS folder attribute files
.DS_Store
.directory

#ignore CLion project files
.idea/
cmake-build-debug/
cmake-build-release/
2 changes: 1 addition & 1 deletion cmake/ElektraConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (NOT elektra_imported_targets)
endif()

set (Elektra_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/@TARGET_INCLUDE_FOLDER@")
set (Elektra_LIBRARIES elektra-core elektra-kdb)
set (Elektra_LIBRARIES elektra-core elektra-kdb elektra-highlevel)

find_path (Elektra_TEMPLATES_DIR
NAMES template.h
Expand Down
2 changes: 1 addition & 1 deletion cmake/elektra.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ templatedir=${prefix}/@TARGET_TEMPLATE_FOLDER@
Name: @PACKAGE_NAME@
Description: @PACKAGE_DESCRIPTION@
Version: @KDB_VERSION@
Libs: -L${libdir} -lelektra-core -lelektra-kdb
Libs: -L${libdir} -lelektra-core -lelektra-kdb -lelektra-highlevel
Cflags: -I${includedir}
17 changes: 11 additions & 6 deletions doc/decisions/high_level_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ sure to use pass a `KeySet`, that has your whole specification included
### Error Handling

```c
const char * elektraErrorMessage (const ElektraError * error);
kdb_boolean_t elektraErrorAbort (const ElektraError * error);
void elektraErrorFree (ElektraError * error)
ElektraErrorCode elektraErrorCode (ElektraError * error);
const char * elektraErrorDescription (ElektraError * error);
ElektraErrorSeverity elektraErrorSeverity (ElektraError * error);
ElektraErrorGroup elektraErrorGroup (ElektraError * error);
ElektraErrorModule elektraErrorModule (ElektraError * error);

void elektraErrorFree (ElektraError * error);

```

`elektraErrorAbort` tells you if you need to quit your application because of severe
issues that are permanent. Otherwise, developers can just print the message and
`elektraErrorSeverity` tells you if you need to quit your application because of severe
issues that are permanent (severity == ELEKTRA_ERROR_SEVERITY_FATAL). Otherwise, developers can just print the message and
continue. (Default settings might be used then.)

### Simple Getters
Expand Down Expand Up @@ -113,7 +118,7 @@ kdb_long_double_t elektraGetLongDouble (Elektra * elektra, const char * name);

```c
size_t elektraArraySize (Elektra * handle, const char * name);
kdb_long_t elektraArrayLong (Elektra * handle, const char * name, size_t elem);
const char * elektraGetStringArrayElement (Elektra * elektra, const char * name, size_t index);
// same types as above

```
Expand Down
1 change: 1 addition & 0 deletions doc/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ provides.
- [Python Bindings](python-kdb.md)
- [Ruby Bindings](/src/bindings/swig/ruby/README.md)
- [Code Generation](/src/tools/gen/README.md)
- [High Level API](/src/libs/highlevel/README.md)

## System Administrators

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/include/kdbcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class Context : public Subject
* @par on_layer is called for every layer in the
* specification.
* @return the evaluated string
*/
*/
std::string evaluate (std::string const & key_name,
std::function<bool(std::string const &, std::string &, bool in_group)> const & on_layer) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/include/kdbplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Delegator

private:
/**This function avoid that every return path need to release the
* configuration. */
* configuration. */
inline static int openHelper (ckdb::Plugin * handle, kdb::KeySet & config, ckdb::Key * errorKey, Builder builder)
{
if (config.lookup ("/module"))
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/glib/gelektra-kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void gelektra_kdb_finalize (GObject * object)

/* Always chain up to the parent class; as with dispose(), finalize()
* is guaranteed to exist on the parent's class virtual function table
*/
*/
G_OBJECT_CLASS (gelektra_kdb_parent_class)->finalize (object);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/glib/gelektra-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void gelektra_key_finalize (GObject * object)

/* Always chain up to the parent class; as with dispose(), finalize()
* is guaranteed to exist on the parent's class virtual function table
*/
*/
G_OBJECT_CLASS (gelektra_key_parent_class)->finalize (object);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/glib/gelektra-keyset.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void gelektra_keyset_finalize (GObject * object)

/* Always chain up to the parent class; as with dispose(), finalize()
* is guaranteed to exist on the parent's class virtual function table
*/
*/
G_OBJECT_CLASS (gelektra_keyset_parent_class)->finalize (object);
}

Expand Down
12 changes: 6 additions & 6 deletions src/bindings/intercept/env/benchmarks/benchmark_getenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ __attribute__ ((noinline)) void benchmark_kslookup ()
using namespace kdb; // needed for KS_END
kdb::KeySet ks (100,
/*
*kdb::Key("user/env/override/some", KEY_END),
*kdb::Key("user/env/override/a/key", KEY_END),
*kdb::Key("user/env/override/b/key", KEY_END),
*kdb::Key("user/env/override/c/key", KEY_END),
*kdb::Key("user/env/override/d/key", KEY_END),
*/
*kdb::Key("user/env/override/some", KEY_END),
*kdb::Key("user/env/override/a/key", KEY_END),
*kdb::Key("user/env/override/b/key", KEY_END),
*kdb::Key("user/env/override/c/key", KEY_END),
*kdb::Key("user/env/override/d/key", KEY_END),
*/
KS_END);
for (int i = 0; i < nr_keys; ++i)
{
Expand Down
22 changes: 22 additions & 0 deletions src/error/exporterrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ ostream & operator<< (ostream & os, parse_t & p)

os << endl << endl;

/* Temporarily disable enum generation.
os << "typedef enum {" << endl;
for (size_t i = 1; i < p.size (); ++i)
{
if (p[i]["unused"] == "yes")
{
continue;
}

if (p[i]["macro"].empty ())
{
continue;
}

os << " ELEKTRA_ERROR_CODE_";
os << p[i]["enum"] << " = " << i << "," << endl;
}
os << "} ElektraErrorCode;" << endl;

os << endl << endl;
*/

for (size_t i = 1; i < p.size (); ++i)
{
if (p[i]["unused"] == "yes")
Expand Down
6 changes: 3 additions & 3 deletions src/error/specification
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ ingroup:kdb

number:9
description:Insufficient permissions to open configuration file for writing. You might want to retry as root.
severity:normal
severity:error
ingroup:kdb
see:75 109 110

number:10
description:general parse error
severity:normal
severity:error
ingroup:kdb
macro:PARSE

Expand Down Expand Up @@ -656,7 +656,7 @@ see:9 75 110

number:110
description:could not open configuration file for reading.
severity:normal
severity:error
ingroup:plugin
module:storage
see:9 75 109
Expand Down
5 changes: 5 additions & 0 deletions src/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ install (FILES
kdbinvoke.h
kdbutility.h
"${CMAKE_CURRENT_BINARY_DIR}/kdbversion.h"
elektra.h
elektra_generic.h
elektra_error.h
elektra_error_codes.h
elektra_conversion.h
DESTINATION include/${TARGET_INCLUDE_FOLDER})


Expand Down
Loading