LCOV - code coverage report
Current view: top level - intl/icu/source/common - uset_props.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 50 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // © 2016 and later: Unicode, Inc. and others.
       2             : // License & terms of use: http://www.unicode.org/copyright.html
       3             : /*
       4             : *******************************************************************************
       5             : *
       6             : *   Copyright (C) 2002-2011, International Business Machines
       7             : *   Corporation and others.  All Rights Reserved.
       8             : *
       9             : *******************************************************************************
      10             : *   file name:  uset_props.cpp
      11             : *   encoding:   UTF-8
      12             : *   tab size:   8 (not used)
      13             : *   indentation:4
      14             : *
      15             : *   created on: 2004aug30
      16             : *   created by: Markus W. Scherer
      17             : *
      18             : *   C wrappers around UnicodeSet functions that are implemented in
      19             : *   uniset_props.cpp, split off for modularization.
      20             : */
      21             : 
      22             : #include "unicode/utypes.h"
      23             : #include "unicode/uobject.h"
      24             : #include "unicode/uset.h"
      25             : #include "unicode/uniset.h"
      26             : #include "cmemory.h"
      27             : #include "unicode/ustring.h"
      28             : #include "unicode/parsepos.h"
      29             : 
      30             : U_NAMESPACE_USE
      31             : 
      32             : U_CAPI USet* U_EXPORT2
      33           0 : uset_openPattern(const UChar* pattern, int32_t patternLength,
      34             :                  UErrorCode* ec)
      35             : {
      36           0 :     UnicodeString pat(patternLength==-1, pattern, patternLength);
      37           0 :     UnicodeSet* set = new UnicodeSet(pat, *ec);
      38             :     /* test for NULL */
      39           0 :     if(set == 0) {
      40           0 :         *ec = U_MEMORY_ALLOCATION_ERROR;
      41           0 :         return 0;
      42             :     }
      43             : 
      44           0 :     if (U_FAILURE(*ec)) {
      45           0 :         delete set;
      46           0 :         set = NULL;
      47             :     }
      48           0 :     return (USet*) set;
      49             : }
      50             : 
      51             : U_CAPI USet* U_EXPORT2
      52           0 : uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
      53             :                  uint32_t options,
      54             :                  UErrorCode* ec)
      55             : {
      56           0 :     UnicodeString pat(patternLength==-1, pattern, patternLength);
      57           0 :     UnicodeSet* set = new UnicodeSet(pat, options, NULL, *ec);
      58             :     /* test for NULL */
      59           0 :     if(set == 0) {
      60           0 :         *ec = U_MEMORY_ALLOCATION_ERROR;
      61           0 :         return 0;
      62             :     }
      63             : 
      64           0 :     if (U_FAILURE(*ec)) {
      65           0 :         delete set;
      66           0 :         set = NULL;
      67             :     }
      68           0 :     return (USet*) set;
      69             : }
      70             : 
      71             : 
      72             : U_CAPI int32_t U_EXPORT2 
      73           0 : uset_applyPattern(USet *set,
      74             :                   const UChar *pattern, int32_t patternLength,
      75             :                   uint32_t options,
      76             :                   UErrorCode *status){
      77             : 
      78             :     // status code needs to be checked since we 
      79             :     // dereference it
      80           0 :     if(status == NULL || U_FAILURE(*status)){
      81           0 :         return 0;
      82             :     }
      83             : 
      84             :     // check only the set paramenter
      85             :     // if pattern is NULL or null terminate
      86             :     // UnicodeString constructor takes care of it
      87           0 :     if(set == NULL){
      88           0 :         *status = U_ILLEGAL_ARGUMENT_ERROR;
      89           0 :         return 0;
      90             :     }
      91             : 
      92           0 :     UnicodeString pat(pattern, patternLength);
      93             : 
      94           0 :     ParsePosition pos;
      95             :    
      96           0 :     ((UnicodeSet*) set)->applyPattern(pat, pos, options, NULL, *status);
      97             :     
      98           0 :     return pos.getIndex();
      99             : }
     100             : 
     101             : U_CAPI void U_EXPORT2
     102           0 : uset_applyIntPropertyValue(USet* set,
     103             :                UProperty prop, int32_t value, UErrorCode* ec) {
     104           0 :     ((UnicodeSet*) set)->applyIntPropertyValue(prop, value, *ec);
     105           0 : }
     106             : 
     107             : U_CAPI void U_EXPORT2
     108           0 : uset_applyPropertyAlias(USet* set,
     109             :                         const UChar *prop, int32_t propLength,
     110             :                         const UChar *value, int32_t valueLength,
     111             :             UErrorCode* ec) {
     112             : 
     113           0 :     UnicodeString p(prop, propLength);
     114           0 :     UnicodeString v(value, valueLength);
     115             : 
     116           0 :     ((UnicodeSet*) set)->applyPropertyAlias(p, v, *ec);
     117           0 : }
     118             : 
     119             : U_CAPI UBool U_EXPORT2
     120           0 : uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
     121             :                       int32_t pos) {
     122             : 
     123           0 :     UnicodeString pat(pattern, patternLength);
     124             : 
     125           0 :     return ((pos+1) < pat.length() &&
     126           0 :             pat.charAt(pos) == (UChar)91/*[*/) ||
     127           0 :             UnicodeSet::resemblesPattern(pat, pos);
     128             : }
     129             : 
     130             : U_CAPI int32_t U_EXPORT2
     131           0 : uset_toPattern(const USet* set,
     132             :                UChar* result, int32_t resultCapacity,
     133             :                UBool escapeUnprintable,
     134             :                UErrorCode* ec) {
     135           0 :     UnicodeString pat;
     136           0 :     ((const UnicodeSet*) set)->toPattern(pat, escapeUnprintable);
     137           0 :     return pat.extract(result, resultCapacity, *ec);
     138             : }
     139             : 
     140             : U_CAPI void U_EXPORT2
     141           0 : uset_closeOver(USet* set, int32_t attributes) {
     142           0 :     ((UnicodeSet*) set)->UnicodeSet::closeOver(attributes);
     143           0 : }

Generated by: LCOV version 1.13