I will murder cmake
							parent
							
								
									0b97f124c5
								
							
						
					
					
						commit
						614ae1c711
					
				|  | @ -1,15 +1,16 @@ | |||
| cmake_minimum_required(VERSION 3.20) | ||||
| project(lander C CXX) | ||||
| 
 | ||||
| set(CMAKE_C_STANDARD 17) | ||||
| set(CMAKE_CXX_STANDARD 11) | ||||
| 
 | ||||
| include_directories(crow/include tries/include) | ||||
| 
 | ||||
| add_subdirectory(crow) | ||||
| add_subdirectory(tries) | ||||
| include_directories(crow/include tries/include) | ||||
| 
 | ||||
| if(CMAKE_BUILD_TYPE STREQUAL Release) | ||||
|     add_compile_options(-O3 -flto) | ||||
| endif() | ||||
| 
 | ||||
| add_executable(lander src/main.cpp) | ||||
| target_link_libraries(lander PUBLIC Crow ternarytrie) | ||||
| target_link_libraries(lander Crow ternarytrie) | ||||
|  |  | |||
|  | @ -1,10 +1,13 @@ | |||
| #include "crow.h" | ||||
| #include "ternarytrie.h" | ||||
| 
 | ||||
| int main() | ||||
| { | ||||
|     TernaryTrie *trie = ternarytrie_init(); | ||||
| 
 | ||||
|     crow::SimpleApp app; | ||||
| 
 | ||||
|     CROW_ROUTE(app, "/")([](){ | ||||
|     CROW_ROUTE(app, "/").methods(crow::HTTPMethod::Get, crow::HTTPMethod::Post)([](){ | ||||
|         return "Hello world"; | ||||
|     }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,8 +1,12 @@ | |||
| cmake_minimum_required(VERSION 3.20) | ||||
| project(AD3-project-2022-2023 C) | ||||
| project(ternarytrie C) | ||||
| 
 | ||||
| set(CMAKE_C_STANDARD 17) | ||||
| 
 | ||||
| include_directories(include) | ||||
| 
 | ||||
| add_library(ternarytrie STATIC include/ternarytrie.h src/ternarytrie.c) | ||||
| add_library(ternarytrie STATIC src/ternarytrie.c) | ||||
| 
 | ||||
| target_include_directories( | ||||
|     ternarytrie PUBLIC | ||||
|     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||||
| ) | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ typedef struct ttrie { | |||
|  * | ||||
|  * @return pointer to the empty TernaryTrie | ||||
|  */ | ||||
| inline TernaryTrie *ternarytrie_init() { | ||||
| TernaryTrie *ternarytrie_init() { | ||||
|   TernaryTrie *node = calloc(1, sizeof(TernaryTrie)); | ||||
|   node->root = ttnode_init(); | ||||
| 
 | ||||
|  | @ -26,7 +26,7 @@ inline TernaryTrie *ternarytrie_init() { | |||
|  * | ||||
|  * @param trie trie to free | ||||
|  */ | ||||
| inline void ternarytrie_free(TernaryTrie *trie) { | ||||
| void ternarytrie_free(TernaryTrie *trie) { | ||||
|   ttnode_free(trie->root); | ||||
|   free(trie); | ||||
| } | ||||
|  | @ -94,7 +94,7 @@ SearchResult ternarytrie_search_node(TernaryTrie *trie, const char *string) { | |||
|  * @param string string to look up | ||||
|  * @return true if the string is present in the trie, false otherwise | ||||
|  */ | ||||
| inline bool ternarytrie_search(TernaryTrie *trie, const char *string) { | ||||
| bool ternarytrie_search(TernaryTrie *trie, const char *string) { | ||||
|   SearchResult res = ternarytrie_search_node(trie, string); | ||||
| 
 | ||||
|   return res.child != NULL; | ||||
|  | @ -244,4 +244,4 @@ bool ternarytrie_remove(TernaryTrie *trie, const char *string) { | |||
|  * @param trie trie to return size for | ||||
|  * @return size of the trie | ||||
|  */ | ||||
| inline size_t ternarytrie_size(TernaryTrie *trie) { return trie->size; } | ||||
| size_t ternarytrie_size(TernaryTrie *trie) { return trie->size; } | ||||
|  |  | |||
|  | @ -51,7 +51,7 @@ void ttnode_free(TernaryTrieNode *node); | |||
|  * @param c character to represent | ||||
|  * @return pointer to newly allocated struct | ||||
|  */ | ||||
| inline TernaryTrieInnerNode *ttinode_init(char c) { | ||||
| TernaryTrieInnerNode *ttinode_init(char c) { | ||||
|   TernaryTrieInnerNode *node = calloc(1, sizeof(TernaryTrieInnerNode)); | ||||
|   node->key = c; | ||||
| 
 | ||||
|  | @ -63,7 +63,7 @@ inline TernaryTrieInnerNode *ttinode_init(char c) { | |||
|  * | ||||
|  * @return pointer to newly allocated struct | ||||
|  */ | ||||
| inline TernaryTrieNode *ttnode_init() { return calloc(1, sizeof(TernaryTrieNode)); } | ||||
| TernaryTrieNode *ttnode_init() { return calloc(1, sizeof(TernaryTrieNode)); } | ||||
| 
 | ||||
| /**
 | ||||
|  * Free a TernaryTrieInnerNode and its underlying tree structure. This should | ||||
|  | @ -109,7 +109,7 @@ void ttnode_free(TernaryTrieNode *node) { | |||
|  * @param node node to add string to | ||||
|  * @param string string to add | ||||
|  */ | ||||
| inline void ttnode_set_string(TernaryTrieNode *node, const char *string) { | ||||
| void ttnode_set_string(TernaryTrieNode *node, const char *string) { | ||||
|   node->type = 2; | ||||
|   node->size = strlen(string); | ||||
|   node->ptr.string = my_strdup(string); | ||||
|  | @ -301,7 +301,7 @@ void ttinode_remove(TernaryTrieInnerNode *node, const char c) { | |||
|  * @param node node to remove character from | ||||
|  * @param c character to remove | ||||
|  */ | ||||
| inline void ttnode_remove(TernaryTrieNode *node, const char c) { | ||||
| void ttnode_remove(TernaryTrieNode *node, const char c) { | ||||
|   ttinode_remove(node->ptr.root, c); | ||||
| 
 | ||||
|   node->size--; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue