Skip to content

Commit e65c996

Browse files
committed
Fixed defines
1 parent 3fee68a commit e65c996

17 files changed

+439
-277
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ project(mapcode_cpp)
2121
# export ASAN_OPTIONS=debug=true:strict_string_checks=1:detect_stack_use_after_return=true:detect_invalid_pointer_pairs=99999:
2222
# detect_container_overflow=true:detect_odr_violation=2:check_initialization_order=true
2323
#
24-
# And add -DNO_POSIX_THREADS to the compiler options if you do not want to use multi-threaded unit testing.
24+
# Compiler directives:
25+
#
26+
# NO_POSIX_THREADS - No multi-threaded unit testing.
27+
# NO_FAST_ENCODE - Drop fast encoding support.
28+
# NO_SUPPORT_ALPHABETS - Drop alphabet support.
29+
# LIMIT_TO_MICRODEGREES - Limit mapcode utility using microdegrees.
2530

26-
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -Wall -fsanitize=address -fno-common -fno-optimize-sibling-calls -fno-omit-frame-pointer")
31+
set(CMAKE_C_FLAGS_DEBUG "-O0 -DNO_FAST_ENCODE -DNO_ALPHABET_SUPPORT -g -DDEBUG -Wall -fsanitize=address -fno-common -fno-optimize-sibling-calls -fno-omit-frame-pointer")
2732
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DDEBUG")
2833
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
2934

README.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
**Latest stable release: https://github.com/mapcode-foundation/mapcode-cpp/releases**
1111

12-
# The C/C++ Library: `mapcodelib/`
12+
## The C/C++ Library: `mapcodelib/`
1313

1414
The directory 'mapcodelib' contains the files:
1515

@@ -45,7 +45,7 @@ In that case, basics.h will state a version number of the for:
4545
where "xxx" states the geographical limitation.
4646

4747

48-
# A Real-Life Example, The 'mapcode' Codec Tool: `utility/`
48+
## A Real-Life Example, The 'mapcode' Codec Tool: `utility/`
4949

5050
The directory 'utility' contains a Mapcode encoding/decoding utility, as an example
5151
of how to use the library.
@@ -121,15 +121,38 @@ This produces the following help text:
121121
The result code is 0 when no error occurred, 1 if an input error occurred and 2
122122
if an internal error occurred.
123123

124-
If you use **Microsoft Visual C++**, you may need to add the following defines to your preprocessor
125-
settings:
124+
## Compile Options for Microsoft Visual C++
126125

127-
NO_POSIX_THREADS
128-
_CRT_SECURE_NO_WARNINGS
129-
_CRT_NONSTDC_NO_DEPRECATE
126+
If you use **Microsoft Visual C++**, you may need to add the following compiler directives to your build:
130127

128+
-DNO_POSIX_THREADS
129+
-D_CRT_SECURE_NO_WARNINGS
130+
-D_CRT_NONSTDC_NO_DEPRECATE
131131

132-
# Release Notes
132+
## Reducing the Footprint of the Mapcode Library
133+
134+
The Mapcode C/C++ Library has includes a number of fixed data tables, which increase its footprint.
135+
You may not require all of this data, so we've added some options for you to be able to reduce its
136+
footprint, for example for embedded applications.
137+
138+
### Removing Alphabet Support: NO_SUPPORT_ALPHABETS
139+
140+
By default, support is included for multiple alphabets (or scripts) other than Roman, such as Greek,
141+
Cyrillic, Hebrew, Arabic, Chinese and many, many more. This means you can encode and decode mapcodes
142+
in such scripts (in UTF16).
143+
144+
You can disabled alphabet support by adding the following compiler directive:
145+
146+
-DNO_SUPPORT_ALPHABETS
147+
148+
### Removing Fast Encoding Support: NO_FAST_ENCODE
149+
150+
By default, encoding is optimized by the use of a additional data table (approx. 12K). You can
151+
remove this table from the library by adding the compiler directive:
152+
153+
-DNO_FAST_ENCODE
154+
155+
## Release Notes
133156

134157
### 2.4.1
135158

mapcodelib/internal_data.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#ifndef __INTERNAL_DATA_H__
1717
#define __INTERNAL_DATA_H__
1818

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
1922

2023
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
2124

@@ -16541,5 +16544,9 @@ static const TerritoryBoundary territoryBoundaries[MAPCODE_BOUNDARY_MAX + 1] = {
1654116544

1654216545
#endif // MAKE_SOURCE_DIGITAL
1654316546

16547+
#ifdef __cplusplus
16548+
}
16549+
#endif
16550+
1654416551
#endif // __INTERNAL_DATA_H__
1654516552

mapcodelib/internal_iso3166_data.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#ifndef __INTERNAL_ISO3166_DATA_H__
1818
#define __INTERNAL_ISO3166_DATA_H__
1919

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
2024
#include "mapcode_territories.h"
2125

2226
// *** GENERATED FILE (dividemaps/fast_territories), DO NOT CHANGE OR PRETTIFY ***
@@ -987,4 +991,8 @@ static const alphaRec alphaSearch[NRTERREC] = {
987991
};
988992

989993
// produced by dividemaps.cpp : fast_territories.cpp
994+
#ifdef __cplusplus
995+
}
996+
#endif
997+
990998
#endif // __INTERNAL_ISO3166_DATA_H__

mapcodelib/internal_territory_alphabets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
extern "C" {
2424
#endif
2525

26+
#ifdef NO_SUPPORT_ALPHABETS
27+
#error "NO_SUPPORT_ALPHABETS cannot be specified in this file"
28+
#endif
29+
2630
#include "mapcoder.h"
2731

2832
static const TerritoryAlphabets alphabetsForTerritory[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {

mapcodelib/internal_territory_names_english.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#ifndef __INTERNAL_TERRITORY_NAMES_ENGLISH_H__
1717
#define __INTERNAL_TERRITORY_NAMES_ENGLISH_H__
1818

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
1923
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
2024
static const char *isofullname[] = {
2125
"Vatican (Holy See)",
@@ -553,4 +557,8 @@ static const char *isofullname[] = {
553557
"International (Worldwide) (Earth)",
554558
"?"};
555559

560+
#ifdef __cplusplus
561+
}
562+
#endif
563+
556564
#endif // __INTERNAL_TERRITORY_NAMES_ENGLISH_H__

mapcodelib/internal_territory_names_english_full.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#ifndef __INTERNAL_TERRITORY_NAMES_ENGLISH_H__
1717
#define __INTERNAL_TERRITORY_NAMES_ENGLISH_H__
1818

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
1923
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
2024
static const char *isofullname[] = {
2125
"Vatican (Holy See)",
@@ -553,4 +557,8 @@ static const char *isofullname[] = {
553557
"International (Worldwide) (Earth)",
554558
"?"};
555559

560+
#ifdef __cplusplus
561+
}
562+
#endif
563+
556564
#endif // __INTERNAL_TERRITORY_NAMES_ENGLISH_H__

mapcodelib/internal_territory_names_local.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515
*/
1616
#ifndef __INTERNAL_TERRITORY_NAMES_LOCAL_H__
1717
#define __INTERNAL_TERRITORY_NAMES_LOCAL_H__
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
1822
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
1923

24+
#ifdef NO_SUPPORT_ALPHABETS
25+
#error "NO_SUPPORT_ALPHABETS cannot be specified in this file"
26+
#endif
2027

2128
/*
2229
* The first N names are precisely in the alphabets
@@ -560,4 +567,8 @@ static const char *localname_utf8[] = {
560567
"Earth",
561568
"?"};
562569

570+
#ifdef __cplusplus
571+
}
572+
#endif
573+
563574
#endif // __INTERNAL_TERRITORY_NAMES_LOCAL_H__

mapcodelib/internal_territory_search.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
#ifndef __INTERNAL_TERRITORY_SEARCH_H__
1818
#define __INTERNAL_TERRITORY_SEARCH_H__
1919

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
2024
// *** GENERATED FILE (dividemaps.cpp), DO NOT CHANGE OR PRETTIFY ***
2125

26+
#ifdef NO_FAST_ENCODE
27+
#error
28+
#error "NO_FAST_ENCODE cannot be specified in this file"
29+
#endif
30+
2231
static int redivar[] = {
2332
27984500, 1383,
2433
2537718, 676,
@@ -810,4 +819,9 @@ static int redivar[] = {
810819
TERRITORY_RU_SA, TERRITORY_RUS,
811820
0
812821
}; // 2924 records, data version 2.3.0
822+
823+
#ifdef __cplusplus
824+
}
825+
#endif
826+
813827
#endif // __INTERNAL_TERRITORY_SEARCH_H__

mapcodelib/mapcode_alphabets.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@
1616
#ifndef __MAPCODE_ALPHABETS_H__
1717
#define __MAPCODE_ALPHABETS_H__
1818

19-
2019
#ifdef __cplusplus
2120
extern "C" {
2221
#endif
2322

23+
#ifdef NO_SUPPORT_ALPHABETS
24+
#error "NO_SUPPORT_ALPHABETS cannot be specified in this file"
25+
#endif
26+
27+
/**
28+
* Mapcodes are suppored in a variety of alphabets, using UTF16. The following
29+
* enum specifies the alphabets (or scripts, as they are also called).
30+
* The 'default' alphabet is Roman, which is always supported. Other
31+
* alphabets may not be supported by every application that accepts
32+
* mapcodes.
33+
*/
2434
enum Alphabet {
2535
_ALPHABET_MIN = -1,
2636
ALPHABET_ROMAN,

0 commit comments

Comments
 (0)