LCOV - code coverage report
Current view: top level - gcc/rust/util - rust-unicode.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.8 % 16 15
Test Date: 2024-04-27 14:03:13 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
       2                 :             : 
       3                 :             : // This file is part of GCC.
       4                 :             : 
       5                 :             : // GCC is free software; you can redistribute it and/or modify it under
       6                 :             : // the terms of the GNU General Public License as published by the Free
       7                 :             : // Software Foundation; either version 3, or (at your option) any later
       8                 :             : // version.
       9                 :             : 
      10                 :             : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11                 :             : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12                 :             : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13                 :             : // for more details.
      14                 :             : 
      15                 :             : // You should have received a copy of the GNU General Public License
      16                 :             : // along with GCC; see the file COPYING3.  If not see
      17                 :             : // <http://www.gnu.org/licenses/>.
      18                 :             : 
      19                 :             : #ifndef RUST_UNICODE_H
      20                 :             : #define RUST_UNICODE_H
      21                 :             : 
      22                 :             : #include "optional.h"
      23                 :             : #include "rust-system.h"
      24                 :             : #include "rust-input-source.h"
      25                 :             : 
      26                 :             : namespace Rust {
      27                 :             : 
      28                 :      322159 : class Utf8String
      29                 :             : {
      30                 :             : private:
      31                 :             :   std::vector<Codepoint> chars;
      32                 :             : 
      33                 :             : public:
      34                 :             :   static tl::optional<Utf8String>
      35                 :      161076 :   make_utf8_string (const std::string &maybe_utf8)
      36                 :             :   {
      37                 :      161076 :     BufferInputSource input_source = {maybe_utf8, 0};
      38                 :      161076 :     tl::optional<std::vector<Codepoint>> chars_opt = input_source.get_chars ();
      39                 :      161076 :     if (chars_opt.has_value ())
      40                 :      322152 :       return {Utf8String (chars_opt.value ())};
      41                 :             :     else
      42                 :           0 :       return tl::nullopt;
      43                 :      161076 :   }
      44                 :             : 
      45                 :      269646 :   Utf8String (const std::vector<Codepoint> codepoints) : chars ({codepoints}) {}
      46                 :             : 
      47                 :      108570 :   std::string as_string () const
      48                 :             :   {
      49                 :      108570 :     std::stringstream ss;
      50                 :      496042 :     for (Codepoint c : chars)
      51                 :      387472 :       ss << c.as_string ();
      52                 :             : 
      53                 :      108570 :     return ss.str ();
      54                 :      108570 :   };
      55                 :             : 
      56                 :             :   // Returns characters
      57                 :       52506 :   std::vector<Codepoint> get_chars () const { return chars; }
      58                 :             : 
      59                 :             :   Utf8String nfc_normalize () const;
      60                 :             : };
      61                 :             : 
      62                 :             : bool
      63                 :             : is_alphabetic (uint32_t codepoint);
      64                 :             : 
      65                 :             : bool
      66                 :             : is_ascii_only (const std::string &str);
      67                 :             : 
      68                 :             : bool
      69                 :             : is_numeric (uint32_t codepoint);
      70                 :             : 
      71                 :             : bool
      72                 :             : is_nfc_qc_no (uint32_t codepoint);
      73                 :             : 
      74                 :             : bool
      75                 :             : is_nfc_qc_maybe (uint32_t codepoint);
      76                 :             : 
      77                 :             : enum class QuickCheckResult
      78                 :             : {
      79                 :             :   YES,
      80                 :             :   NO,
      81                 :             :   MAYBE
      82                 :             : };
      83                 :             : 
      84                 :             : QuickCheckResult
      85                 :             : nfc_quick_check (const std::vector<Codepoint> &s);
      86                 :             : 
      87                 :             : } // namespace Rust
      88                 :             : 
      89                 :             : #if CHECKING_P
      90                 :             : 
      91                 :             : namespace selftest {
      92                 :             : 
      93                 :             : void
      94                 :             : rust_nfc_qc_test ();
      95                 :             : 
      96                 :             : void
      97                 :             : rust_utf8_normalize_test ();
      98                 :             : 
      99                 :             : void
     100                 :             : rust_utf8_property_test ();
     101                 :             : 
     102                 :             : } // namespace selftest
     103                 :             : 
     104                 :             : #endif // CHECKING_P
     105                 :             : 
     106                 :             : #endif
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.