Eina

Date
  2008 (created)

# Table of Contents

- Introduction
- How to compile
- Next Steps
- Introductory Example

# Introduction

The Eina library is a library which implements an API for data types in an efficient way. It also provides some useful tools like opening shared libraries, error management, type conversion, time accounting and memory pools.

This library is cross-platform and can be compiled and used on Linux, BSD, and Windows.

The data types available are (see Data Types):

- Fp standard floating point numbers.
- Inline Array standard array of inlined members.
- Array standard array of `void*` data.
- Hash Table standard hash of `void*` data.
- Inline List list with nodes inlined into user type.
- Compact List Compact List.
- List standard list of `void*` data.
- Iterator Functions Iterator functions.
- Sparse Matrix sparse matrix of `void*` data.
- Red-Black tree red-black tree with nodes inlined into user type.
- String Buffer mutable string to prepend, insert or append strings to a buffer.
- Stringshare saves memory by sharing read-only string references.
- Tiler split, merge and navigates into 2D tiled regions.
- Trash container of unused but allocated data.
- Generic Value Storage container for generic value storage and access.

The tools available are (see Tools):

- Benchmark helper to write benchmarks.
- Convert faster conversion from strings to integers, double, etc.
- Counter measures number of calls and their time.
- Cpu Cpu and architecture related helpers.
- Error error identifiers.
- File simple file list and path split.
- Lazy allocator simple lazy allocator.
- Log full-featured logging system.
- Magic provides runtime type checking.
- Memory Pool abstraction for various memory allocators.
- Module lists, loads and share modules using Eina_Module standard.
- Rectangle rectangle structure and standard manipulation methods.
- Safety Checks extra checks that will report unexpected conditions and can be disabled at compile time.
- String a set of functions that manages C strings.

# How to compile

Eina is a library to which your app can link. The procedure for this is very simple. You simply have to compile your application with the appropriate compiler flags as outputted by the `pkg-config` script. For example:

Compiling C or C++ files into object files:

    gcc -c -o main.o main.c `pkg-config --cflags eina`

Linking object files into a binary executable:

    gcc -o my_application main.o `pkg-config --libs eina`

See pkgconfig

# Next Steps

After you've understood what Eina is and installed it, you can now learn more about the the programming interface.

Recommended reading:

- Data Types to find about implemented types and how to use them.
- Tools to find about helper tools provided by eina.

# Introductory Example

//Compile with:
//gcc -g eina_list_01.c -o eina_list_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int
main(int argc, char **argv)
{
(void)argc;
(void)argv;
Eina_List *list = NULL;
Eina_List *l;
void *list_data;
eina_init();
list = eina_list_append(list, "tigh");
list = eina_list_append(list, "adar");
list = eina_list_append(list, "baltar");
list = eina_list_append(list, "roslin");
EINA_LIST_FOREACH(list, l, list_data)
printf("%s\n", (char*)list_data);
printf("\n");
l = eina_list_nth_list(list, 1);
list = eina_list_append_relative_list(list, "cain", l);
list = eina_list_append_relative(list, "zarek", "cain");
list = eina_list_prepend(list, "adama");
list = eina_list_prepend_relative(list, "gaeta", "cain");
list = eina_list_prepend_relative_list(list, "lampkin", l);
EINA_LIST_FOREACH(list, l, list_data)
printf("%s\n", (char*)list_data);
eina_list_free(list);
eina_shutdown();
return 0;
}
Eina.h
Eina Utility library.
eina_list_append_relative
EINA_API Eina_List * eina_list_append_relative(Eina_List *list, const void *data, const void *relative)
Inserts the given data into the given linked list after the specified data.
Definition eina_list.c:649
eina_list_prepend
EINA_API Eina_List * eina_list_prepend(Eina_List *list, const void *data)
Prepends the given data to the given linked list.
Definition eina_list.c:618
eina_list_nth_list
EINA_API Eina_List * eina_list_nth_list(const Eina_List *list, unsigned int n)
Gets the nth member's list node in a list.
Definition eina_list.c:1006
eina_list_append
EINA_API Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition eina_list.c:584
Eina_List
struct _Eina_List Eina_List
Type for a generic double linked list.
Definition eina_list.h:304
eina_list_prepend_relative
EINA_API Eina_List * eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative)
Prepends a data pointer to a linked list before the specified member.
Definition eina_list.c:704
eina_list_free
EINA_API Eina_List * eina_list_free(Eina_List *list)
Frees an entire list and all the nodes, ignoring the data contained.
Definition eina_list.c:823
eina_list_append_relative_list
EINA_API Eina_List * eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative)
Appends a list node to a linked list after the specified member.
Definition eina_list.c:670
eina_list_prepend_relative_list
EINA_API Eina_List * eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative)
Prepends a list node to a linked list before the specified member.
Definition eina_list.c:724
EINA_LIST_FOREACH
#define EINA_LIST_FOREACH(list, l, _data)
Definition for the macro to iterate over a list.
Definition eina_list.h:1415
eina_shutdown
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition eina_main.c:379
eina_init
EINA_API int eina_init(void)
Initializes the Eina library.
Definition eina_main.c:291

More examples can be found at Eina Examples.