Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /*
0003  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004  *
0005  * This file is part of Opticks
0006  * (see https://bitbucket.org/simoncblyth/opticks).
0007  *
0008  * Licensed under the Apache License, Version 2.0 (the "License"); 
0009  * you may not use this file except in compliance with the License.  
0010  * You may obtain a copy of the License at
0011  *
0012  *   http://www.apache.org/licenses/LICENSE-2.0
0013  *
0014  * Unless required by applicable law or agreed to in writing, software 
0015  * distributed under the License is distributed on an "AS IS" BASIS, 
0016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017  * See the License for the specific language governing permissions and 
0018  * limitations under the License.
0019  */
0020 
0021 /**
0022 SBit
0023 =====
0024 
0025 **/
0026 
0027 #include "SYSRAP_API_EXPORT.hh"
0028 #include "SYSRAP_HEAD.hh"
0029 #include <string>
0030 
0031 struct SYSRAP_API SBit 
0032 {
0033     // ffs returns 1-based index of rightmost set bit, see man ffs 
0034     static int ffs(int msk);
0035     static long long ffsll(long long msk);
0036 
0037     static unsigned long long count_nibbles(unsigned long long x); 
0038 
0039     static bool HasOneSetBit(int x); 
0040 
0041 
0042     template <typename T> static std::string BinString(T v, bool anno=true); 
0043     template <typename T> static std::string HexString(T v, bool anno=true); 
0044     template <typename T> static std::string DecString(T v, bool anno=false); 
0045     template <typename T> static std::string PosString(T v, char delim=',', bool anno=false); 
0046 
0047     template <typename T> static std::string String(T v); 
0048 
0049     static const char* ANNO ; 
0050     static const char* ParseAnnotation(bool& complement, char& anno, const char* str_ );
0051 
0052     static unsigned long long FromBinString(const char* str ) ; 
0053     static unsigned long long FromHexString(const char* str ) ; 
0054     static unsigned long long FromDecString(const char* str ) ; 
0055     static unsigned long long FromPosString(const char* str, char delim=',') ; 
0056 
0057     static unsigned long long FromString(const char* str ) ; 
0058 
0059     static constexpr const char* ALL = "~0" ; 
0060     static unsigned long long FromEString(const char* ekey, const char* fallback=ALL ); 
0061 }; 
0062 
0063 #include "SYSRAP_TAIL.hh"
0064 
0065