Skip to content

Commit

Permalink
Add a README.md for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Apr 11, 2024
1 parent b079f38 commit 1a5b15a
Show file tree
Hide file tree
Showing 2 changed files with 692 additions and 0 deletions.
46 changes: 46 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Examples of LiteString usage

This directory contains examples of using the LiteString library.

Before building the examples, make sure that the LiteString library is built or installed.

For building the LiteString library, refer to the [README](../README.md) file in the root directory.

## C API

[word stats](./word_stats.c) - Counts the number of characters and words in a text file.

The text file should not be bigger than 1MB.

```bash
gcc -o word_stats word_stats.c -L /path/to/libLiteString.a -llite_string
./word_stats blindtext.txt
```

## C++ API

[grep clone](./cheap_grep.cpp) - A simple clone of the `grep` command.

```bash
g++ -o cheap_grep cheap_grep.cpp -L /path/to/libLiteString.a -llite_string
./cheap_grep -i "ipsum dolor" blindtext.txt
```

## Building with CMake

The [CMakeLists.txt](./CMakeLists.txt) file in this directory can be used to build the examples.

```bash
# From this directory (examples), run:
mkdir build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build build -j 4
```

The examples can be found in the `build` directory.

```bash
# From this directory (examples), run:
./build/word_stats blindtext.txt
./build/cheap_grep -i "ipsum dolor" blindtext.txt
```
Loading

0 comments on commit 1a5b15a

Please sign in to comment.