Flutter Engine
 
Loading...
Searching...
No Matches
comments_util.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6#include "flutter/third_party/re2/re2/re2.h"
7
8static RE2 kAddTrimLineRegex(R"regex(^(?:\s*(?://|#)\s?))regex");
10 R"regex(^(?:\s*\**\s)?(.*?)(?:\s*\**\s*)?$)regex");
11static RE2 kAddCEndTrimLineRegex(R"regex(^\s*(.*?)\*/)regex");
12
13void CommentsUtil::AddTrimLine(std::string* buffer,
14 const char* text,
15 size_t length) {
16 std::string chopped(text, length);
17 RE2::Replace(&chopped, kAddTrimLineRegex, "");
18 buffer->append(chopped);
19}
20
21void CommentsUtil::AddCTrimLine(std::string* buffer,
22 const char* text,
23 size_t length) {
24 re2::StringPiece captured_content;
25 RE2::PartialMatch(re2::StringPiece(text), kAddCTrimLineRegex,
26 &captured_content);
27 buffer->append(captured_content);
28 buffer->push_back('\n');
29}
30
31void CommentsUtil::AddCEndTrimLine(std::string* buffer,
32 const char* text,
33 size_t length) {
34 re2::StringPiece captured_content;
35 RE2::PartialMatch(re2::StringPiece(text), kAddCEndTrimLineRegex,
36 &captured_content);
37 buffer->append(captured_content);
38}
static void AddCEndTrimLine(std::string *buffer, const char *text, size_t length)
static void AddCTrimLine(std::string *buffer, const char *text, size_t length)
static void AddTrimLine(std::string *buffer, const char *text, size_t length)
static RE2 kAddCTrimLineRegex(R"regex(^(?:\s*\**\s)?(.*?)(?:\s*\**\s*)?$)regex")
static RE2 kAddTrimLineRegex(R"regex(^(?:\s*(?://|#)\s?))regex")
static RE2 kAddCEndTrimLineRegex(R"regex(^\s*(.*?)\*/)regex")
size_t length
std::u16string text