Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – initializing the native store


We need to create and initialize all the structures we will use for the next section of the chapter:

  1. Create the jni/Store.h file, which defines store data structures:

    • The StoreType enumeration will reflect the corresponding Java enumeration. Leave it empty for now.

    • The StoreValue union will contain any of the possible store values. Leave it empty for now too.

    • The StoreEntry structure contains one piece of data in the store. It is composed of a key (a raw C string made from char*), a type (StoreType), and a value (StoreValue).

      Note

      Note that we will see how to set up and use C++ STL strings in Chapter 9, Porting Existing Libraries to Android.

    • Store is the main structure that defines a fixed size array of entries and a length (that is, the number of allocated entries):

      #ifndef _STORE_H_
      #define _STORE_H_
      
      #include <cstdint>
      
      #define STORE_MAX_CAPACITY 16
      
      typedef enum {
      } StoreType;
      
      typedef union {
      } StoreValue;
      
      typedef struct {
          char* mKey...