util.hh (cfe30d02adda7c3b5c76156ac52d50d8cab325d9) | util.hh (bbe31b709a653884e18995a1c97cdafd7392999a) |
---|---|
1/*- 2 * Copyright (c) 2013 David Chisnall 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 54 unchanged lines hidden (view full) --- 63 static_assert(sizeof(T) > 1, 64 "Big endian doesn't make sense for single-byte values"); 65 for (int bit=(sizeof(T) - 1)*8 ; bit>=0 ; bit-= 8) 66 { 67 v.push_back((val >> bit) & 0xff); 68 } 69} 70 | 1/*- 2 * Copyright (c) 2013 David Chisnall 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 54 unchanged lines hidden (view full) --- 63 static_assert(sizeof(T) > 1, 64 "Big endian doesn't make sense for single-byte values"); 65 for (int bit=(sizeof(T) - 1)*8 ; bit>=0 ; bit-= 8) 66 { 67 v.push_back((val >> bit) & 0xff); 68 } 69} 70 |
71void push_string(byte_buffer &v, const std::string &s, bool escapes=false); 72 |
|
71/** 72 * Simple inline non-locale-aware check that this is a valid ASCII 73 * digit. 74 */ 75inline bool isdigit(char c) 76{ 77 return (c >= '0') && (c <= '9'); 78} 79 80/** 81 * Simple inline non-locale-aware check that this is a valid ASCII 82 * hex digit. 83 */ 84inline bool ishexdigit(char c) 85{ 86 return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || | 73/** 74 * Simple inline non-locale-aware check that this is a valid ASCII 75 * digit. 76 */ 77inline bool isdigit(char c) 78{ 79 return (c >= '0') && (c <= '9'); 80} 81 82/** 83 * Simple inline non-locale-aware check that this is a valid ASCII 84 * hex digit. 85 */ 86inline bool ishexdigit(char c) 87{ 88 return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || |
87 ((c >= 'A') && (c <= 'Z')); | 89 ((c >= 'A') && (c <= 'F')); |
88} 89 | 90} 91 |
92/** 93 * Simple inline non-locale-aware check that this is a valid ASCII 94 * letter. 95 */ 96inline bool isalpha(char c) 97{ 98 return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')); 99} 100 101/** 102 * A wrapper around dirname(3) that handles inconsistencies relating to memory 103 * management between platforms and provides a std::string interface. 104 */ 105std::string dirname(const std::string&); 106 107/** 108 * A wrapper around basename(3) that handles inconsistencies relating to memory 109 * management between platforms and provides a std::string interface. 110 */ 111std::string basename(const std::string&); 112 |
|
90}// namespace dtc 91 92#endif // !_UTIL_HH_ | 113}// namespace dtc 114 115#endif // !_UTIL_HH_ |