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
5
#include "
flutter/tools/licenses_cpp/src/comments_util.h
"
6
#include "flutter/third_party/re2/re2/re2.h"
7
8
static
RE2
kAddTrimLineRegex
(R
"regex(^(?:\s*(?://|#)\s?))regex");
9
static
RE2
kAddCTrimLineRegex
(
10
R
"regex(^(?:\s*\**\s)?(.*?)(?:\s*\**\s*)?$)regex");
11
static
RE2
kAddCEndTrimLineRegex
(R
"regex(^\s*(.*?)\*/)regex");
12
13
void
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
21
void
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
31
void
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
}
CommentsUtil::AddCEndTrimLine
static void AddCEndTrimLine(std::string *buffer, const char *text, size_t length)
Definition
comments_util.cc:31
CommentsUtil::AddCTrimLine
static void AddCTrimLine(std::string *buffer, const char *text, size_t length)
Definition
comments_util.cc:21
CommentsUtil::AddTrimLine
static void AddTrimLine(std::string *buffer, const char *text, size_t length)
Definition
comments_util.cc:13
kAddCTrimLineRegex
static RE2 kAddCTrimLineRegex(R"regex(^(?:\s*\**\s)?(.*?)(?:\s*\**\s*)?$)regex")
kAddTrimLineRegex
static RE2 kAddTrimLineRegex(R"regex(^(?:\s*(?://|#)\s?))regex")
kAddCEndTrimLineRegex
static RE2 kAddCEndTrimLineRegex(R"regex(^\s*(.*?)\*/)regex")
comments_util.h
length
size_t length
Definition
key_event_handler.cc:41
text
std::u16string text
Definition
keyboard_unittests.cc:332
tools
licenses_cpp
src
comments_util.cc
Generated on Thu Nov 6 2025 16:11:30 for Flutter Engine by
1.9.8