⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvgutil.cpp

📁 开源的电子海图程序
💻 CPP
字号:
/* GHelm - Nautical Navigation Software * Copyright (C) 2004 Jon Michaelchuck * * This application is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA. */#include "cvgutil.h"#include <sstream>#include <iostream>std::string _get_suffix(std::string str, std::string delim){    std::string::size_type foo;	foo = str.find_first_of(delim);    std::string suffix = str.substr(foo+1);     return suffix;}std::string _get_prefix(std::string str, std::string delim){    std::string::size_type foo;	foo = str.find_first_of(delim);    std::string prefix = str.substr(0, foo);     return prefix;}std::string _remove_whitespace(std::string str){    while (isspace(str[str.length()-1]))        str.erase(str.length()-1);    while (isspace(*(str.begin())))        str.erase(str.begin());    return str;}int _hex_to_dec(std::string str){    const char *hexStg = str.c_str();    int n = 0;         // position in string    int m = 0;         // position in digit[] to shift    int count;         // loop index    int intValue = 0;  // integer value of hex string    int digit[5];      // hold values to convert    while (n < 4) {     if (hexStg[n]=='\0')        break;     if (hexStg[n] > 0x29 && hexStg[n] < 0x40 ) //if 0 to 9        digit[n] = hexStg[n] & 0x0f;            //convert to int     else if (hexStg[n] >='a' && hexStg[n] <= 'f') //if a to f        digit[n] = (hexStg[n] & 0x0f) + 9;      //convert to int     else if (hexStg[n] >='A' && hexStg[n] <= 'F') //if A to F        digit[n] = (hexStg[n] & 0x0f) + 9;      //convert to int     else break;    n++;    }    count = n;    m = n - 1;    n = 0;    while(n < count) {     // digit[n] is value of hex digit at position n     // (m << 2) is the number of positions to shift     // OR the bits into return value     intValue = intValue | (digit[n] << (m << 2));     m--;   // adjust the position to set     n++;   // next digit to process    }    return (intValue);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -