Run clang-format
This commit is contained in:
@@ -1,61 +1,61 @@
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
void open_document_and_display_gui(std::string const& filename)
|
||||
{}
|
||||
|
||||
bool done_editing()
|
||||
void
|
||||
open_document_and_display_gui(std::string const& filename)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
enum command_type{
|
||||
open_new_document
|
||||
bool
|
||||
done_editing()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
enum command_type { open_new_document };
|
||||
|
||||
struct user_command {
|
||||
command_type type;
|
||||
|
||||
user_command() : type(open_new_document) {}
|
||||
};
|
||||
|
||||
|
||||
struct user_command
|
||||
user_command
|
||||
get_user_input()
|
||||
{
|
||||
command_type type;
|
||||
|
||||
user_command():
|
||||
type(open_new_document)
|
||||
{}
|
||||
};
|
||||
|
||||
user_command get_user_input()
|
||||
{
|
||||
return user_command();
|
||||
return user_command();
|
||||
}
|
||||
|
||||
std::string get_filename_from_user()
|
||||
std::string
|
||||
get_filename_from_user()
|
||||
{
|
||||
return "foo.doc";
|
||||
return "foo.doc";
|
||||
}
|
||||
|
||||
void process_user_input(user_command const& cmd)
|
||||
{}
|
||||
|
||||
void edit_document(std::string const& filename)
|
||||
void
|
||||
process_user_input(user_command const& cmd)
|
||||
{
|
||||
open_document_and_display_gui(filename);
|
||||
while(!done_editing())
|
||||
{
|
||||
user_command cmd=get_user_input();
|
||||
if(cmd.type==open_new_document)
|
||||
{
|
||||
std::string const new_name=get_filename_from_user();
|
||||
std::thread t(edit_document,new_name);
|
||||
t.detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
process_user_input(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edit_document(std::string const& filename)
|
||||
{
|
||||
open_document_and_display_gui(filename);
|
||||
while (!done_editing()) {
|
||||
user_command cmd = get_user_input();
|
||||
if (cmd.type == open_new_document) {
|
||||
std::string const new_name = get_filename_from_user();
|
||||
std::thread t(edit_document, new_name);
|
||||
t.detach();
|
||||
}
|
||||
else {
|
||||
process_user_input(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
edit_document("bar.doc");
|
||||
edit_document("bar.doc");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user