void init(void) { parser_init(); lispy = parser_get(); env = lenv_new(); builtins_init(env); _parse("(def {nil} {})"); _parse("(def {true} 1)"); _parse("(def {otherwise} true)"); _parse( "(def {function} (lambda {args body} {\ def (head args) (lambda (tail args) body)\ }))"
static void _fill_defaults (void) { int i; for (i = 0; i < NUM_PORT_ELEMENTS; ++i) { if (!port_cfg[0][i].any && strcasecmp(port_spec[i].def, NO_DEFAULT)) _parse(&(port_cfg[0][i]), (char *)port_spec[i].def, port_spec[i].type, port_spec[i].boolint_def); } for (i = 0; i < NUM_GEN_ELEMENTS; ++i) { if (!general_cfg[i].any && strcasecmp(gen_spec[i].def, NO_DEFAULT)) _parse(&(general_cfg[i]), (char *)gen_spec[i].def, gen_spec[i].type, gen_spec[i].boolint_def); } }
//-------------------------------------------------------------------------------------------------------- // Write functions //-------------------------------------------------------------------------------------- void CInifile::w_string( LPCSTR S, LPCSTR L, LPCSTR V, LPCSTR comment) { R_ASSERT (!m_flags.test(eReadOnly)); // section string256 sect; _parse (sect,S); _strlwr (sect); if (!section_exist(sect)) { // create _new_ section Sect *NEW = new Sect(); NEW->Name = sect; RootIt I = std::lower_bound(DATA.begin(),DATA.end(),sect,sect_pred); DATA.insert (I,NEW); } // parse line/value string4096 line; _parse (line,L); string4096 value; _parse (value,V); // duplicate & insert Item I; Sect& data = r_section (sect); I.first = (line[0]?line:0); I.second = (value[0]?value:0); #ifdef DEBUG I.comment = (comment?comment:0); #endif SectIt_ it = std::lower_bound(data.Data.begin(),data.Data.end(),*I.first,item_pred); if (it != data.Data.end()) { // Check for "first" matching if (0==xr_strcmp(*it->first, *I.first)) { BOOL b = m_flags.test(eOverrideNames); R_ASSERT2(b,make_string("name[%s] already exist in section[%s]",line,sect).c_str()); *it = I; } else { data.Data.insert(it,I); } } else { data.Data.insert(it,I); } }
QVariant LooseJSON::parse(QByteArray data) { QBuffer buffer; buffer.setBuffer(&data); buffer.open(QIODevice::ReadOnly); QVariant dat = _parse(&buffer); return dat; }
the::filesystem::splitfile::splitfile(strref filename) { if(!the::filesystem::is_file(filename)) FATAL_ERROR("[File ] can't open file '%s'",filename.c_str()); wholeFile = the::filesystem::load_as_string(filename); _parse(); }
static int _parse_array(char **s, struct json_result *result) { int rc; struct json_array *array = visit_array_start(result); while (1) { rc = _parse(s, result); if (!rc) return 0; rc = visit_array_add(result, array); if (!rc) return 0; eat_whitespace(s); if (**s == ']') { ++*s; break; } else if (**s == ',') { ++*s; eat_whitespace(s); } else { return 0; } } visit_array_end(result, array); return 1; }
GETOPT_INLINE GetOpt_pp::GetOpt_pp(int argc, char* argv[], _EnvTag) : _first_token(NULL), _last_token(NULL) { _init_flags(); _parse(argc, argv); _parse_env(); }
bool DatabaseSQLite::executeQuery(const std::string &query) { OTSYS_THREAD_LOCK_CLASS lockClass(sqliteLock); if(!m_connected) return false; #ifdef __SQL_QUERY_DEBUG__ std::cout << "SQLITE QUERY: " << query << std::endl; #endif std::string buf = _parse(query); sqlite3_stmt* stmt; // prepares statement if(OTSYS_SQLITE3_PREPARE(m_handle, buf.c_str(), buf.length(), &stmt, NULL) != SQLITE_OK) { sqlite3_finalize(stmt); std::cout << "OTSYS_SQLITE3_PREPARE(): SQLITE ERROR: " << sqlite3_errmsg(m_handle) << " (" << buf << ")" << std::endl; return false; } // executes it once int32_t ret = sqlite3_step(stmt); if(ret != SQLITE_OK && ret != SQLITE_DONE && ret != SQLITE_ROW) { sqlite3_finalize(stmt); std::cout << "sqlite3_step(): SQLITE ERROR: " << sqlite3_errmsg(m_handle) << std::endl; return false; } // closes statement // at all not sure if it should be debugged - query was executed correctly... sqlite3_finalize(stmt); return true; }
// // _readDocument: // bool XMLTableParser::_readDocument(void){ // parse the XML file _parse(_rootElement); // if the table is empty, exit if(_columns < 1) { xmlFreeDoc(_document); xmlCleanupParser(); return false; } // // fill remaining empty slots with missing values to obtain a rectangular block of data // while(_element.size() % _columns != 0) { _element.push_back("."); } _rows = _element.size() / _columns; xmlFreeDoc(_document); xmlCleanupParser(); // DEBUG: // display(); return true; }
DBResult* DatabaseODBC::storeQuery(const std::string &query) { if(!m_connected) return NULL; #ifdef __DEBUG_SQL__ std::cout << "ODBC QUERY: " << query << std::endl; #endif std::string buf = _parse(query); SQLHSTMT stmt; SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_STMT, m_handle, &stmt); if(!RETURN_SUCCESS(ret)){ std::cout << "Failed to allocate ODBC SQLHSTMT statement." << std::endl; return NULL; } ret = SQLExecDirect(stmt, (SQLCHAR*)buf.c_str(), buf.length() ); if(!RETURN_SUCCESS(ret)){ std::cout << "SQLExecDirect(): " << query << ": ODBC ERROR." << std::endl; return NULL; } DBResult* results = new ODBCResult(stmt); return verifyResult(results); }
bool DatabaseODBC::internalQuery(const std::string &query) { if(!m_connected) return false; #ifdef __DEBUG_SQL__ std::cout << "ODBC QUERY: " << query << std::endl; #endif std::string buf = _parse(query); SQLHSTMT stmt; SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_STMT, m_handle, &stmt); if(!RETURN_SUCCESS(ret)){ std::cout << "Failed to allocate ODBC SQLHSTMT statement." << std::endl; return false; } ret = SQLExecDirect(stmt, (SQLCHAR*)buf.c_str(), buf.length() ); if(!RETURN_SUCCESS(ret)){ std::cout << "SQLExecDirect(): " << query << ": ODBC ERROR." << std::endl; return false; } return true; }
DBResult_ptr DatabaseODBC::internalSelectQuery(const std::string &query) { if(!m_connected) return DBResult_ptr(); #ifdef __DEBUG_SQL__ std::cout << "ODBC QUERY: " << query << std::endl; #endif std::string buf = _parse(query); SQLHSTMT stmt; SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_STMT, m_handle, &stmt); if(!RETURN_SUCCESS(ret)){ std::cout << "Failed to allocate ODBC SQLHSTMT statement." << std::endl; return DBResult_ptr(); } ret = SQLExecDirect(stmt, (SQLCHAR*)buf.c_str(), buf.length() ); if(!RETURN_SUCCESS(ret)){ std::cout << "SQLExecDirect(): " << query << ": ODBC ERROR." << std::endl; return DBResult_ptr(); } DBResult_ptr results(new ODBCResult(stmt), boost::bind(&DatabaseDriver::freeResult, this, _1)); return verifyResult(results); }
bool IDbConnection::query(shared_ptr<DbSqlICommand> select, DataTable &table) { String sql; _parse(select, sql); return query(sql, table); }
static Eina_Bool _server_data(void *data, int type, void *event) { Instance *inst; Ecore_Con_Event_Server_Data *ev; inst = data; ev = event; if ((!inst->server) || (inst->server != ev->server)) return EINA_TRUE; while ((inst->cursize + ev->size) >= inst->bufsize) { inst->bufsize += 4096; inst->buffer = realloc(inst->buffer, inst->bufsize); } memcpy(inst->buffer + inst->cursize, ev->data, ev->size); inst->cursize += ev->size; inst->buffer[inst->cursize] = 0; _parse(inst); return EINA_FALSE; }
/*! The following two constructors instantiate the class from existing UUIDs for further processing */ UT_UUID::UT_UUID(const UT_UTF8String &s) { m_bIsValid = _parse(s.utf8_str(), m_uuid); // if the UUID was not valid, we will generate a new one if(!m_bIsValid) makeUUID(); }
GETOPT_INLINE GetOpt_pp::GetOpt_pp(int argc, const char* const* const argv) : _exc(std::ios_base::goodbit), _first_token(NULL), _last_token(NULL), _tokens_deleter(_first_token) { _init_flags(); std::vector<std::string> args; _argc_argv_to_vector(argc, argv, args); _parse(args); }
UT_UUID::UT_UUID(const char * in) { m_bIsValid = _parse(in, m_uuid); // if the UUID was not valid, we will generate a new one if(!m_bIsValid) makeUUID(); }
bool Style::load(const std::string &url, unsigned long projectId) { std::string response; if(loadJSON(url, response)) { return _parse(response, projectId); } return false; }
/* ** Process command line, allocate default buffer to each fd, ** execute main(), and exit to DOS. Must be executed with es=psp. ** Small default buffers are allocated because a high price is paid for ** byte-by-byte calls to DOS. Tests gave these results for a simple ** copy program: ** ** chunk size copy time in seconds ** 1 36 ** 5 12 ** 25 6 ** 50 6 */ _main() { int fd; _parse(); for(fd = 0; fd < MAXFILES; ++fd) auxbuf(fd, 32); if(!isatty(stdin)) _bufuse[stdin] = EMPTY; if(!isatty(stdout)) _bufuse[stdout] = EMPTY; main(_cnt, _vec); exit(0); }
void ParsedJson::_parse(FILE *file) { string _json = ""; while(not feof(file)) { char buf[1024]; fgets(buf, 1024, file); _json += buf; } _parse(_json); }
GETOPT_INLINE GetOpt_pp::GetOpt_pp(int argc, const char* const* const argv, _EnvTag) : _first_token(NULL), _last_token(NULL), _tokens_deleter(_first_token) { _init_flags(); std::vector<std::string> args; _argc_argv_to_vector(argc, argv, args); _parse(args); _parse_env(); }
bool FreeType::render(const Vector2& basePoint, const Vector4& color, const std::string& text ) { if (text.size() == 0) { return true; } Vector2 bp = basePoint; // unsigned short unicode = 0; FTex* fTex = 0; _baseX = bp.x; unsigned int spaceOffset = _fontSize * 0.5; bp.y += _fontSize; // for (size_t i = 0; i < text.size(); ++i) { bool chinese = false; if (text[i] < 0) { unicode = _computeUnicode(text.substr(i, 2)); ++i; chinese = true; } else { unicode = _computeUnicode(text.substr(i, 1)); } // fTex = _parse(unicode, chinese); if (NULL == fTex) { // '\n' if (unicode == 10) { bp.y += _fontSize; _baseX = bp.x; } else { _baseX += spaceOffset; } } else { _renderImpl(fTex, color, bp); } // unicode = 0; fTex = 0; } // return true; }
static void _build_general_config (struct cw_variable *v) { int pos; for (; v; v = v->next) { if (((pos = get_cfg_position(v->name, GEN_CFG)) < 0) || (_parse(&general_cfg[pos], v->value, gen_spec[pos].type, gen_spec[pos].boolint_def) < 0)) CLI_ERROR(v->name, v->value, "general"); } }
/** * 結果の取得 * * @access public * @return void */ void rediscli::_result() { char buf[1024*16]; int nread; evutil_socket_t fd = bufferevent_getfd(bev); nread = read(fd, buf, sizeof(buf)); if (nread <= 0) { return ;; } _parse(buf); }
static void parse_references(parser_data *p_data) { pmh_PRINTF("\nPARSING REFERENCES: "); p_data->parsing_only_references = true; _parse(p_data, yy_References); p_data->parsing_only_references = false; p_data->references = p_data->head_elems[pmh_REFERENCE]; p_data->head_elems[pmh_REFERENCE] = NULL; }
/* * Parse input and produce binary stream * @param stmt_lst statement list * @param sym_tbl symbol table */ void _par::parse( std::vector<std::vector<token_t>> &stmt_lst, std::map<std::string, size_t> &sym_tbl ) { _parse( stmt_lst, sym_tbl ); }
//-------------------------------------------------------------------------------------------------------- // Write functions //-------------------------------------------------------------------------------------- void CInifile::w_string ( LPCSTR S, LPCSTR L, LPCSTR V, LPCSTR comment) { R_ASSERT (!bReadOnly); // section char sect [256]; _parse (sect,S); _strlwr (sect); if (!section_exist(sect)) { // create _new_ section Sect *NEW = xr_new<Sect>(); NEW->Name = sect; RootIt I = std::lower_bound(DATA.begin(),DATA.end(),sect,sect_pred); DATA.insert (I,NEW); } // parse line/value char line [256]; _parse (line,L); char value [256]; _parse (value,V); // duplicate & insert Item I; Sect& data = r_section (sect); I.first = (line[0]?line:0); I.second = (value[0]?value:0); #ifdef DEBUG I.comment = (comment?comment:0); #endif SectIt_ it = std::lower_bound(data.Data.begin(),data.Data.end(),*I.first,item_pred); if (it != data.Data.end()) { // Check for "first" matching if (0==xr_strcmp(*it->first,*I.first)) { *it = I; } else { data.Data.insert(it,I); } } else { data.Data.insert(it,I); } }
int shell_loop(char * line, char cmd[255][255]) { _setup(cmd); _prompt(); if(_read(line)){ _parse(line, cmd); if (exec) _execute(cmd); } else { run = 0; } return 0; }
static void _commandLine(struct Debugger* debugger) { struct CLIDebugger* cliDebugger = (struct CLIDebugger*) debugger; const char* line; _printStatus(cliDebugger, 0); int count = 0; HistEvent ev; while (debugger->state == DEBUGGER_PAUSED) { line = el_gets(cliDebugger->elstate, &count); if (!line) { return; } if (line[0] == '\n') { if (history(cliDebugger->histate, &ev, H_FIRST) >= 0) { _parse(cliDebugger, ev.str, strlen(ev.str) - 1); } } else { _parse(cliDebugger, line, count - 1); history(cliDebugger->histate, &ev, H_ENTER, line); } } }
R _parse_list(T& t, R r, type_list<LL, LR>) { if (_check(r, srange(LL()()))) return _parse(t, r, srange(LL()()) ); return _parse_list( t, r, LR() ); /*R income = r; r = _parse(t, r, srange(LL()()) ); if ( r == income ) return _parse_list( t, r, LR() ); return r; */ }