Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:30

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #pragma once
0021 /**
0022 SASCII
0023 ========
0024 
0025 **/
0026 
0027 
0028 #include <string>
0029 #include <cstddef>
0030 #include "SYSRAP_API_EXPORT.hh"
0031 
0032 template <unsigned> struct SDice ; 
0033 
0034 
0035 class SYSRAP_API SASCII 
0036 {
0037   public:
0038       static const char UPPER[] ;  
0039       static const char LOWER[] ;  
0040       static const char NUMBER[] ;  
0041       static const char OTHER[] ;  
0042       static const char EXTRA[] ;  
0043       static const char ALLOWED[] ;  
0044 
0045   public:
0046       static int Index(const char* arr, int num,  char s ); 
0047       static int LowerIndex(char s); 
0048       static int UpperIndex(char s); 
0049 
0050       static char ToUpper(char s ); 
0051       static char ToLower(char s ); 
0052       static const char* ToUpper( const char* str ); 
0053       static const char* ToLower( const char* str ); 
0054   public:
0055       static unsigned Count( char c, const char* list );  
0056       static bool IsUpper( char c );  
0057       static bool IsLower( char c );  
0058       static bool IsNumber( char c );  
0059       static bool IsOther( char c );  
0060       static bool IsExtra( char c );  
0061       static bool IsAllowed( char c );
0062       static char Classify( char c); 
0063 
0064       static void DumpAllowed();
0065       static void Dump(const char* s);
0066 
0067   public:
0068       SASCII( const char* s_); 
0069       std::string getFirst(unsigned n) const ; 
0070       std::string getFirstUpper(unsigned n) const ; 
0071       std::string getFirstLast() const ; 
0072       std::string getTwoChar(unsigned first, unsigned second) const ; 
0073       std::string getTwoRandom(SDice<26>& rng ) const ; 
0074 
0075       void dump() const ; 
0076 
0077   private:
0078       void init();   
0079   public:
0080       const char* s ; 
0081       unsigned len ; 
0082       unsigned upper; 
0083       unsigned lower; 
0084       unsigned number; 
0085       unsigned other ; 
0086       unsigned extra ; 
0087       unsigned allowed ; 
0088 
0089       int first_upper_index ; 
0090       int first_other_index ; 
0091       int first_extra_index ; 
0092       int first_number_index ; 
0093 };
0094 
0095 
0096 
0097