Skip to content

Commit aa2bed8

Browse files
committed
docs: add README.md and task-description.md
1 parent 06a0adb commit aa2bed8

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Asynchronous Log File Reader [![Code license](https://img.shields.io/github/license/work-examples/async-log-reader)](LICENSE)
2+
3+
**Example project:** Log file reader and filter (`grep` analog).
4+
Application reads specified file and writes matchig lines to `stdout`.
5+
It supports simple regex (`fnmatch` algorithm).
6+
Reading is implemented using direct Win32 API with a number of approaches, including asynchronous WinAPI.
7+
C++ exceptions are not used (forbidden).
8+
9+
**Language**: `C++17`
10+
**Dependencies**: none
11+
**Software requirements**: `Visual Studio 2019`
12+
**Operation systems**: `Windows`
13+
14+
| Branch | CI Build Status | CodeQL Code Analysis |
15+
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16+
| **master** | [![CI status](https://github.com/work-examples/async-log-reader/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/work-examples/async-log-reader/actions/workflows/build.yml?query=branch%3Amaster) | [![CodeQL Code Analysis Status](https://github.com/work-examples/async-log-reader/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/work-examples/async-log-reader/actions/workflows/codeql-analysis.yml?query=branch%3Amaster) |
17+
| **develop** | [![CI status](https://github.com/work-examples/async-log-reader/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/work-examples/async-log-reader/actions/workflows/build.yml?query=branch%3Adevelop) | \[not applicable\] |
18+
19+
## Test Task Description
20+
21+
Detailed task description is provided in a separate document:
22+
23+
- [task-description.md](task-description.md)
24+
25+
## Task Implementation Remarks
26+
27+
Original implementation remarks letter in Russian is provided here:
28+
29+
- [solution-notes-letter.ru.md](solution-notes-letter.ru.md)
30+
31+
---

task-description.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# C++ Programmer's Test Task
2+
3+
It is necessary to write a class in pure C++ that can read huge text log files
4+
(hundreds of megabytes, tens of gigabytes) as quickly as possible and produce lines
5+
that satisfy the conditions of the simplest regexp: (at least the `*` and `?` operators,
6+
a wider range of possibilities are welcome):
7+
8+
- character `*` - sequence of any characters of unlimited length;
9+
- character `?` - any one character;
10+
- masks should be processed correctly: `*Some*`, `*Some`, `Some*`, `*****Some***` -
11+
there are no restrictions on the position `*` in the mask.
12+
13+
The search result must be strings that match the mask.
14+
15+
For example:
16+
17+
- The mask `*abc*` selects all lines containing `abc` and starting and ending with any sequence of characters.
18+
- The `abc*` mask matches all strings starting with `abc` and ending with any sequence of characters.
19+
- The `abc?` mask selects all lines starting with `abc` and ending with any additional character.
20+
- The `abc` mask selects all strings that are equal to this mask.
21+
22+
The class will not be extended and will not be a base class.
23+
24+
Character encoding: all files and regex patterns are ANSI (non-unicode single-byte encoding).
25+
26+
The class must have the following public interface:
27+
28+
```cpp
29+
class CLogReader
30+
{
31+
public:
32+
CLogReader(...);
33+
~CLogReader(...);
34+
35+
bool Open(...); // opening a file, false - error
36+
void Close(); // close the file
37+
38+
bool SetFilter(const char *filter); // setting the line filter, false - error
39+
bool GetNextLine(char *buf, // request for the next matched line,
40+
const int bufsize); // buf - buffer, bufsize - maximum length
41+
// false - end of file or error
42+
};
43+
```
44+
45+
## Implementation Requirements
46+
47+
- Platform: Windows 7 and above
48+
- Functionality: maximum performance (caching of search results and file is not required)
49+
- Resources: memory costs should be minimal (within reasonable limits)
50+
- Components: use of third-party libraries (including STL) and components is prohibited.
51+
Only WinAPI and CRT are allowed.
52+
- Exceptions: Windows and C++ exceptions cannot be used
53+
- The code must be absolutely "indestructible" and protected from errors
54+
55+
## Design Requirements
56+
57+
- The code should be as simple as possible
58+
- The code should be as clean, beautiful and understandable as possible
59+
- The result should be a finished class (`.cpp` + `.h` files) and a console example app
60+
which opens a text file of a couple of megabytes and greps `order*closed`.
61+
- The console example app should receive the path to the text file (the first parameter)
62+
and the line filter(the second parameter) as command line parameters and output
63+
the found lines in full to the console. Run line example:
64+
`tool.exe 20190102.log *bbb*`
65+
- The project must be designed for building in MS Visual Studio 2015 and higher.
66+
67+
Any comments in the code are welcome! `:)`
68+
69+
---

0 commit comments

Comments
 (0)