Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit321041f

Browse files
committed
Run clang-format on contrib/
1 parente468d94 commit321041f

File tree

12 files changed

+498
-594
lines changed

12 files changed

+498
-594
lines changed

‎contrib/http_examples/atom/atom.cpp‎

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,91 @@
44
// (See accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7-
87
#include"atom.hpp"
98
#include"../rapidxml/rapidxml.hpp"
109
#include<stdexcept>
1110
#include<cassert>
1211

1312
namespacenetwork {
1413
namespaceatom {
15-
feed::feed(const http::client::response &response) {
16-
std::string response_body =body(response);
17-
rapidxml::xml_document<> doc;
18-
doc.parse<0>(const_cast<char *>(response_body.c_str()));
19-
20-
rapidxml::xml_node<> *feed = doc.first_node("feed");
21-
if (!feed) {
22-
throwstd::runtime_error("Invalid atom feed.");
14+
feed::feed(const http::client::response& response) {
15+
std::string response_body =body(response);
16+
rapidxml::xml_document<> doc;
17+
doc.parse<0>(const_cast<char*>(response_body.c_str()));
18+
19+
rapidxml::xml_node<>* feed = doc.first_node("feed");
20+
if (!feed) {
21+
throwstd::runtime_error("Invalid atom feed.");
22+
}
23+
24+
rapidxml::xml_node<>* title = feed->first_node("title");
25+
if (title) {
26+
title_ = title->first_node()->value();
27+
}
28+
29+
rapidxml::xml_node<>* subtitle = feed->first_node("subtitle");
30+
if (subtitle) {
31+
subtitle_ = subtitle->first_node()->value();
32+
}
33+
34+
rapidxml::xml_node<>* id = feed->first_node("id");
35+
if (id) {
36+
id_ = id->first_node()->value();
37+
}
38+
39+
rapidxml::xml_node<>* updated = feed->first_node("updated");
40+
if (updated) {
41+
updated_ = updated->first_node()->value();
42+
}
43+
44+
rapidxml::xml_node<>* author = feed->first_node("author");
45+
if (author) {
46+
rapidxml::xml_node<>* name = author->first_node("name");
47+
rapidxml::xml_node<>* email = author->first_node("email");
48+
if (name && email) {
49+
author_ =atom::author(name->first_node()->value(),
50+
email->first_node()->value());
51+
}elseif (name) {
52+
author_ =atom::author(name->first_node()->value());
2353
}
54+
}
55+
56+
rapidxml::xml_node<>* entry = feed->first_node("entry");
57+
while (entry) {
58+
entries_.push_back(atom::entry());
2459

25-
rapidxml::xml_node<> *title =feed->first_node("title");
60+
rapidxml::xml_node<>*title =entry->first_node("title");
2661
if (title) {
27-
title_ =title->first_node()->value();
62+
entries_.back().set_title(title->first_node()->value());
2863
}
2964

30-
rapidxml::xml_node<> *subtitle = feed->first_node("subtitle");
31-
if (subtitle) {
32-
subtitle_ = subtitle->first_node()->value();
65+
rapidxml::xml_node<>* id = entry->first_node("id");
66+
if (id) {
67+
entries_.back().set_id(id->first_node()->value());
3368
}
3469

35-
rapidxml::xml_node<> *id = feed->first_node("id");
36-
if (id) {
37-
id_ = id->first_node()->value();
70+
rapidxml::xml_node<>* published = entry->first_node("published");
71+
if (published) {
72+
entries_.back().set_published(published->first_node()->value());
3873
}
3974

40-
rapidxml::xml_node<> *updated =feed->first_node("updated");
75+
rapidxml::xml_node<>*updated =entry->first_node("updated");
4176
if (updated) {
42-
updated_ =updated->first_node()->value();
77+
entries_.back().set_updated(updated->first_node()->value());
4378
}
4479

45-
rapidxml::xml_node<> *author = feed->first_node("author");
46-
if (author) {
47-
rapidxml::xml_node<> *name = author->first_node("name");
48-
rapidxml::xml_node<> *email = author->first_node("email");
49-
if (name && email) {
50-
author_ =atom::author(name->first_node()->value(), email->first_node()->value());
51-
}
52-
elseif (name) {
53-
author_ =atom::author(name->first_node()->value());
54-
}
80+
rapidxml::xml_node<>* summary = entry->first_node("summary");
81+
if (summary) {
82+
entries_.back().set_summary(summary->first_node()->value());
5583
}
5684

57-
rapidxml::xml_node<> *entry = feed->first_node("entry");
58-
while (entry) {
59-
entries_.push_back(atom::entry());
60-
61-
rapidxml::xml_node<> *title = entry->first_node("title");
62-
if (title) {
63-
entries_.back().set_title(title->first_node()->value());
64-
}
65-
66-
rapidxml::xml_node<> *id = entry->first_node("id");
67-
if (id) {
68-
entries_.back().set_id(id->first_node()->value());
69-
}
70-
71-
rapidxml::xml_node<> *published = entry->first_node("published");
72-
if (published) {
73-
entries_.back().set_published(published->first_node()->value());
74-
}
75-
76-
rapidxml::xml_node<> *updated = entry->first_node("updated");
77-
if (updated) {
78-
entries_.back().set_updated(updated->first_node()->value());
79-
}
80-
81-
rapidxml::xml_node<> *summary = entry->first_node("summary");
82-
if (summary) {
83-
entries_.back().set_summary(summary->first_node()->value());
84-
}
85-
86-
rapidxml::xml_node<> *content = entry->first_node("content");
87-
if (content) {
88-
entries_.back().set_content(content->first_node()->value());
89-
}
90-
91-
entry = entry->next_sibling();
85+
rapidxml::xml_node<>* content = entry->first_node("content");
86+
if (content) {
87+
entries_.back().set_content(content->first_node()->value());
9288
}
89+
90+
entry = entry->next_sibling();
91+
}
9392
}
94-
}// namespace atom
95-
}// namespace network
93+
}// namespace atom
94+
}// namespace network

‎contrib/http_examples/atom/atom.hpp‎

Lines changed: 60 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -5,172 +5,116 @@
55
// http://www.boost.org/LICENSE_1_0.txt)
66

77
#ifndef ___ATOM_INC__
8-
#define___ATOM_INC__
9-
10-
11-
#include<string>
12-
#include<vector>
13-
#include<network/http/client.hpp>
8+
#define___ATOM_INC__
149

10+
#include<string>
11+
#include<vector>
12+
#include<network/http/client.hpp>
1513

1614
namespacenetwork {
1715
namespaceatom {
1816
classentry {
1917

20-
public:
18+
public:
2119

22-
voidset_title(const std::string &title) {
23-
title_ = title;
24-
}
20+
voidset_title(const std::string& title) { title_ = title; }
2521

26-
std::stringtitle()const {
27-
return title_;
28-
}
22+
std::stringtitle()const {return title_; }
2923

30-
voidset_id(const std::string &id) {
31-
id_ = id;
32-
}
24+
voidset_id(const std::string& id) { id_ = id; }
3325

34-
std::stringid()const {
35-
return id_;
36-
}
26+
std::stringid()const {return id_; }
3727

38-
voidset_published(const std::string &published) {
39-
published_ = published;
40-
}
28+
voidset_published(const std::string& published) { published_ = published; }
4129

42-
std::stringpublished()const {
43-
return published_;
44-
}
30+
std::stringpublished()const {return published_; }
4531

46-
voidset_updated(const std::string &updated) {
47-
updated_ = updated;
48-
}
32+
voidset_updated(const std::string& updated) { updated_ = updated; }
4933

50-
std::stringupdated()const {
51-
return updated_;
52-
}
34+
std::stringupdated()const {return updated_; }
5335

54-
voidset_summary(const std::string &summary) {
55-
summary_ = summary;
56-
}
36+
voidset_summary(const std::string& summary) { summary_ = summary; }
5737

58-
std::stringsummary()const {
59-
return summary_;
60-
}
38+
std::stringsummary()const {return summary_; }
6139

62-
voidset_content(const std::string &content) {
63-
content_ = content;
64-
}
40+
voidset_content(const std::string& content) { content_ = content; }
6541

66-
std::stringcontent()const {
67-
return content_;
68-
}
42+
std::stringcontent()const {return content_; }
6943

70-
private:
44+
private:
7145

72-
std::string title_;
73-
std::string id_;
74-
std::string published_;
75-
std::string updated_;
76-
std::string summary_;
77-
std::string content_;
46+
std::string title_;
47+
std::string id_;
48+
std::string published_;
49+
std::string updated_;
50+
std::string summary_;
51+
std::string content_;
7852

7953
};
8054

8155
classauthor {
8256

83-
public:
84-
85-
author() {
86-
87-
}
88-
89-
author(const std::string &name)
90-
: name_(name) {
57+
public:
9158

92-
}
59+
author() {}
9360

94-
author(const std::string &name,const std::string &email)
95-
: name_(name), email_(email) {
61+
author(const std::string& name) : name_(name) {}
9662

97-
}
63+
author(const std::string& name,const std::string& email)
64+
: name_(name),
65+
email_(email) {}
9866

99-
std::stringname()const {
100-
return name_;
101-
}
67+
std::stringname()const {return name_; }
10268

103-
std::stringemail()const {
104-
return email_;
105-
}
69+
std::stringemail()const {return email_; }
10670

107-
private:
71+
private:
10872

109-
std::string name_;
110-
std::string email_;
73+
std::string name_;
74+
std::string email_;
11175

11276
};
11377

11478
classfeed {
11579

116-
public:
117-
typedef entry value_type;
118-
typedef std::vector<entry>::iterator iterator;
119-
typedef std::vector<entry>::const_iterator const_iterator;
80+
public:
81+
typedef entry value_type;
82+
typedef std::vector<entry>::iterator iterator;
83+
typedef std::vector<entry>::const_iterator const_iterator;
12084

121-
feed(const http::client::response &response);
85+
feed(const http::client::response&response);
12286

123-
std::stringtitle()const {
124-
return title_;
125-
}
87+
std::stringtitle()const {return title_; }
12688

127-
std::stringsubtitle()const {
128-
return subtitle_;
129-
}
89+
std::stringsubtitle()const {return subtitle_; }
13090

131-
std::stringid()const {
132-
return id_;
133-
}
91+
std::stringid()const {return id_; }
13492

135-
std::stringupdated()const {
136-
return updated_;
137-
}
93+
std::stringupdated()const {return updated_; }
13894

139-
atom::authorauthor()const {
140-
return author_;
141-
}
95+
atom::authorauthor()const {return author_; }
14296

143-
unsignedintentry_count()const {
144-
return entries_.size();
145-
}
97+
unsignedintentry_count()const {return entries_.size(); }
14698

147-
iteratorbegin() {
148-
return entries_.begin();
149-
}
99+
iteratorbegin() {return entries_.begin(); }
150100

151-
iteratorend() {
152-
return entries_.end();
153-
}
101+
iteratorend() {return entries_.end(); }
154102

155-
const_iteratorbegin()const {
156-
return entries_.begin();
157-
}
103+
const_iteratorbegin()const {return entries_.begin(); }
158104

159-
const_iteratorend()const {
160-
return entries_.end();
161-
}
105+
const_iteratorend()const {return entries_.end(); }
162106

163-
private:
107+
private:
164108

165-
std::string title_;
166-
std::string subtitle_;
167-
std::string id_;
168-
std::string updated_;
169-
atom::author author_;
170-
std::vector<entry> entries_;
109+
std::string title_;
110+
std::string subtitle_;
111+
std::string id_;
112+
std::string updated_;
113+
atom::author author_;
114+
std::vector<entry> entries_;
171115

172116
};
173-
}// namespace atom
174-
}// namespace network
117+
}// namespace atom
118+
}// namespace network
175119

176-
#endif// ___ATOM_INC__
120+
#endif// ___ATOM_INC__

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp