source: cpp/frams/util/validitychecks.cpp @ 718

Last change on this file since 718 was 651, checked in by Maciej Komosinski, 8 years ago

0,1 -> false,true

  • Property svn:eol-style set to native
File size: 1004 bytes
RevLine 
[286]1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
[109]4
[375]5#include "validitychecks.h"
[109]6#include <frams/util/sstringutils.h>
[375]7#include <common/log.h>
[109]8
9bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun)
10{
11        int size=list->size();
12if ((index<0)||(index>=size))
13        {
14        if (size>0)
[375]15                logPrintf(msgobj,msgfun,LOG_ERROR,"Invalid index %d (allowed range is 0..%d)",index,size-1);
[109]16        else
[375]17                logPrintf(msgobj,msgfun,LOG_ERROR,"Invalid index %d (this list is empty)",index);
[651]18        return false;
[109]19        }
[651]20return true;
[109]21}
22
[512]23SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(const SString& in))
[109]24{
25if (!checker)
26        checker=trim;
27SString corrected=checker(in);
28if (corrected!=in)
29        {
30        SString msg2=SString(msg)+": \"%s\" (adjusted to \"%s\")";
[375]31        logPrintf(msgobj,msgfun,LOG_WARN,msg2.c_str(),in.c_str(),corrected.c_str());
[109]32        }
33return corrected;
34}
Note: See TracBrowser for help on using the repository browser.