Skip to content

Commit

Permalink
remove every occurance of #define CROW_MAIN.
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
  • Loading branch information
luca-schlecker committed Nov 21, 2021
1 parent 5823a59 commit e5c7dac
Show file tree
Hide file tree
Showing 18 changed files with 13 additions and 33 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Available [here](https://crowcpp.org).

#### Hello World
```cpp
#define CROW_MAIN
#include "crow.h"

int main()
Expand Down
7 changes: 1 addition & 6 deletions docs/getting_started/your_first_application.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
This page shows how you can get started with a simple hello world application.

## 1. Include
Starting with an empty `main.cpp` file, first add `#!cpp #define CROW_MAIN` then `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file.

!!! note

If you're using multiple C++ source files make sure to have `CROW_MAIN` defined only in your main source file.
Starting with an empty `main.cpp` file, first add `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file.

## 2. App declaration
Next Create a `main()` and declare a `#!cpp crow::SimpleApp` inside, your code should look like this
Expand Down Expand Up @@ -39,7 +35,6 @@ Please note that the `port()` and `multithreaded()` methods aren't needed, Thoug
Once you've followed all the steps above, your code should look similar to this

``` cpp linenums="1"
#define CROW_MAIN //let the compiler know this is your main cpp file
#include "crow.h"
//#include "crow_all.h"

Expand Down
2 changes: 1 addition & 1 deletion docs/overrides/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h1 style="text-align:center;">A Fast and Easy to use microframework for the web
<h2 style="text-align: center;">Easy to get started</h3>
</div>
<div class="scontent">
<div class="highlight"><pre id="__code_0"><span></span><button class="md-clipboard md-icon" title="Copy to clipboard" data-clipboard-target="#__code_0 > code"></button><code><span class="cp">#define CROW_MAIN</span>
<div class="highlight"><pre id="__code_0"><span></span><button class="md-clipboard md-icon" title="Copy to clipboard" data-clipboard-target="#__code_0 > code"></button><code>
<span class="cp">#include</span> <span class="cpf">"crow.h"</span><span class="cp"></span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
Expand Down
1 change: 0 additions & 1 deletion examples/example.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"

#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion examples/example_blueprint.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"

int main()
Expand Down
1 change: 0 additions & 1 deletion examples/example_catchall.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include <crow.h>


Expand Down
1 change: 0 additions & 1 deletion examples/example_chat.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"
#include <string>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion examples/example_compression.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"
#include "crow/compression.h"

Expand Down
1 change: 0 additions & 1 deletion examples/example_json_map.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#define CROW_JSON_USE_MAP
#include "crow.h"

Expand Down
7 changes: 3 additions & 4 deletions examples/example_static_file.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//#define CROW_STATIC_DRIECTORY "alternative_directory/"
//#define CROW_STATIC_ENDPOINT "/alternative_endpoint/<path>"
//#define CROW_DISABLE_STATIC_DIR
#define CROW_MAIN
#include "crow.h"

int main()
Expand All @@ -18,10 +17,10 @@ CROW_ROUTE(app, "/")
res.end();
});


app.port(18080).run();


return 0;
}

Expand Down
7 changes: 3 additions & 4 deletions examples/example_vs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"

#include <sstream>
Expand All @@ -10,7 +9,7 @@ class ExampleLogHandler : public crow::ILogHandler {
}
};

struct ExampleMiddleware
struct ExampleMiddleware
{
std::string message;

Expand Down Expand Up @@ -108,7 +107,7 @@ int main()
app.route_dynamic("/params")
([](const crow::request& req){
std::ostringstream os;
os << "Params: " << req.url_params << "\n\n";
os << "Params: " << req.url_params << "\n\n";
os << "The key 'foo' was " << (req.url_params.get("foo") == nullptr ? "not " : "") << "found.\n";
if(req.url_params.get("pew") != nullptr) {
double countD = boost::lexical_cast<double>(req.url_params.get("pew"));
Expand All @@ -120,7 +119,7 @@ int main()
os << " - " << countVal << '\n';
}
return crow::response{os.str()};
});
});

// ignore all log
crow::logger::setLogLevel(crow::LogLevel::Debug);
Expand Down
5 changes: 2 additions & 3 deletions examples/example_with_all.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow_all.h"

#include <sstream>
Expand Down Expand Up @@ -96,7 +95,7 @@ int main()
CROW_ROUTE(app, "/params")
([](const crow::request& req){
std::ostringstream os;
os << "Params: " << req.url_params << "\n\n";
os << "Params: " << req.url_params << "\n\n";
os << "The key 'foo' was " << (req.url_params.get("foo") == nullptr ? "not " : "") << "found.\n";
if(req.url_params.get("pew") != nullptr) {
double countD = boost::lexical_cast<double>(req.url_params.get("pew"));
Expand All @@ -108,7 +107,7 @@ int main()
os << " - " << countVal << '\n';
}
return crow::response{os.str()};
});
});

// ignore all log
crow::logger::setLogLevel(crow::LogLevel::Debug);
Expand Down
1 change: 0 additions & 1 deletion examples/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"

int main()
Expand Down
3 changes: 1 addition & 2 deletions examples/ssl/example_ssl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"

int main()
Expand All @@ -14,7 +13,7 @@ int main()

// Use .pem file
//app.port(18080).ssl_file("test.pem").run();

// Use custom context; see boost::asio::ssl::context
/*
* crow::ssl_context_t ctx;
Expand Down
3 changes: 1 addition & 2 deletions examples/websocket/example_ws.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CROW_MAIN
#include "crow.h"
#include <unordered_set>
#include <mutex>
Expand Down Expand Up @@ -38,7 +37,7 @@ int main()
gethostname(name, 256);
crow::mustache::context x;
x["servername"] = name;

auto page = crow::mustache::load("ws.html");
return page.render(x);
});
Expand Down
2 changes: 1 addition & 1 deletion include/crow/http_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace crow
{
*this = std::move(r);
}

response(std::string contentType, std::string body) : body(std::move(body))
{
set_header("Content-Type", mime_types.at(contentType));
Expand Down
1 change: 0 additions & 1 deletion tests/ssl/ssltest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#define CATCH_CONFIG_MAIN
#define CROW_LOG_LEVEL 0
#define CROW_MAIN

#include <thread>

Expand Down
1 change: 0 additions & 1 deletion tests/unittest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#define CATCH_CONFIG_MAIN
#define CROW_ENABLE_DEBUG
#define CROW_LOG_LEVEL 0
#define CROW_MAIN
#include <sys/stat.h>

#include <iostream>
Expand Down

0 comments on commit e5c7dac

Please sign in to comment.