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

📄 parse.h

📁 该文件是包含了机器人足球比赛中的整个系统的代码
💻 H
字号:
#ifndef PARSE_H
#define PARSE_H

#include <vector>
#include <stdlib.h>
#include <stdio.h>

// these define the maximum number of characters in a key, and in a value
#define MAX_KEYLENGTH 64
#define MAX_VALLENGTH 64

using namespace std;

struct Pair {
  char* key; // note max lengths above
  char* val;
};

class Parse {
  public:
    Parse();
    void WriteFile(const char* filename, const char* buffer, int buffersize);
    void ParseFile(const char* filename);

    // probably should never call this externally, but there's no technical reason why you can't ...
    void RegisterPair(char* k, char* v);

    int GetAsInt(const char* k);
    bool GetAsBool(const char* k);
    char* GetAsString(const char* k);
    double GetAsDouble(const char* k);

  private:
    // don't mess with this.
    Pair* FindPair(const char* k);
    Pair* FindPairFailFast(const char* k);

    bool IsTerminator(const char c);
    bool IsLF(const char c);
    bool IsSpace(const char c);

    vector<Pair> keyValuePairs;
};

#endif

⌨️ 快捷键说明

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