<commit_before># High Level C++ ZMQ API

## Prerequisites
The following are required to build the ZMQCPP api:
* CMake
* The ZMQ libraries (ubuntu/debian package libzmq3-dev
* A modern C++ compiler supporting C++11 (clang++ 3.x, g++ 4.7+)

## Build Instructions

This software uses CMake as it's build system; as such out of source builds are preferred.

You should create a build directory in the source directory and cd to it.

To prepare for release (from the build directory) :
`cmake .. && make zmqcpp`

To run code coverage:
`cmake .. -DCMAKE_BUILD_TYPE=Debug && make zmqcpp_coverage`

To generate Cobertura xml output for code coverage:
`cmake .. -DCMAKE_BUILD_TYPE=Debug && make zmqcpp_cobertura`<commit_msg>Getting Started section in README<commit_after># High Level C++ ZMQ API

## Prerequisites
The following are required to build the ZMQCPP api:
* CMake
* The ZMQ libraries (ubuntu/debian package libzmq3-dev
* A modern C++ compiler supporting C++11 (clang++ 3.x, g++ 4.7+)

## Build Instructions

This software uses CMake as it's build system; as such out of source builds are preferred.

You should create a build directory in the source directory and cd to it.

To prepare for release (from the build directory) :
`cmake .. && make zmqcpp`

To run code coverage:
`cmake .. -DCMAKE_BUILD_TYPE=Debug && make zmqcpp_coverage`

To generate Cobertura xml output for code coverage:
`cmake .. -DCMAKE_BUILD_TYPE=Debug && make zmqcpp_cobertura`

## Getting Started

### Creating sockets
Creating a socket is as easy as `zmqcpp::Socket sock_name(ZMQ_SOCKTYPE)`.  Examples
```c++
zmqcpp::Socket send(ZMQ_PUSH);
zmqcpp::Socket recv(ZMQ_PULL);

//bind and connect using the appropriate function
sendsock.bind(BIND_ADDR);
recvsock.connect(CONN_ADDR);
```
The need for a Context is hidden in a singleton class; if you absolutely need to get the automatically created context:
```c++
zmqcpp::Context c;
c.get();
// or
zmqcpp::Context::get();

### Using sockets
All communication through sockets must happen through the `zmqcpp::BaseMessage<T>` interface.  One basic message type is defined: `zmqcpp::Message`.  Messages can be created using the templated constructor; if the << operator is overloaded to allow insertion into a stringstream, and the resulting string is the correct format, the Message constructor will work just fine.
```c++
zmqcpp::Message m1(1);
zmqcpp::Message m2("hello");
```
More complex (read: multi-frame) messages can be created using the `add_frame` method
```c++
zmqcpp::Message m3;
m3.add_frame("hello");
m3.add_frame("world");
```
Messages can then be sent/received one of two ways:
```c++
zmqcpp::Message rec;
std::string last_recvd;
sendsock.send(m1);
recvsock.recv(rec);
last_recvd = *(rec.frames().back()); // contains the last frame received, last_recvd == "1"
```
Or
```c++
sendsock << m3;
recvsock >> rec;
cout << *(rec.frames().back()) << endl; // prints "hello" to the screen
revsock >> rec; // rec's frame list now contains "1", "hello", "world"
cout << *(rec.frames().back()) << endl; // prints "world" to the screen
```

More complex message types can be created by inheriting from the base message type; these messages can handle special protocol messages, etc.
{'fraction_non_alphanumeric': 0.1146158650843223, 'fraction_numerical': 0.006870705808869456, 'mean_word_length': 5.009380863039399, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1607950', 'n_tokens_mistral': 1025, 'n_tokens_neox': 971, 'n_words': 404}