source: cpp/frams/errmgr/stderrors.cpp @ 348

Last change on this file since 348 was 348, checked in by Maciej Komosinski, 9 years ago
  • explicit c_str() in SString instead of (const char*) cast
  • genetic converters and GenMan? are now thread-local which enables multi-threaded simulator separation
  • Property svn:eol-style set to native
File size: 989 bytes
Line 
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.
4
5#include "stderrors.h"
6#include <frams/util/sstringutils.h>
7#include <common/framsg.h>
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)
15                FMprintf(msgobj,msgfun,FMLV_ERROR,"Invalid index %d (allowed range is 0..%d)",index,size-1);
16        else
17                FMprintf(msgobj,msgfun,FMLV_ERROR,"Invalid index %d (this list is empty)",index);
18        return 0;
19        }
20return 1;
21}
22
23SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in))
24{
25if (!checker)
26        checker=trim;
27SString corrected=checker(in);
28if (corrected!=in)
29        {
30        SString msg2=SString(msg)+": \"%s\" (adjusted to \"%s\")";
31        FMprintf(msgobj,msgfun,FMLV_WARN,msg2.c_str(),in.c_str(),corrected.c_str());
32        }
33return corrected;
34}
Note: See TracBrowser for help on using the repository browser.