void CAipi_STableGlobalLiteral::editSTableLiteralValue(long id, tstring value)
{
	CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
	CMainFrame::g_mSTableGlobalLiteral::iterator iter;
	if( !pMainFrame->gmSTableGlobalLiteral.empty())
	{
		int found = findSTableLiteralMembers( id );
		if( found != NOT_FOUND )
		{
			pMainFrame->gmSTableGlobalLiteral.erase(id);
			addSymbol(m_STGLitId, m_STGLitName, m_STGLitType, value);
		
			CString str;
			AfxMessageBox(_T("OLD VALUE"));
			str.Format(m_STGLitValue.data());
			AfxMessageBox(str);
			AfxMessageBox(_T("EDIT VALUE"));
			str.Format(value.data());
			AfxMessageBox(str);
			str.Format(_T("%d" ), m_STGLitType);
			AfxMessageBox(str);
			AfxMessageBox(m_STGLitName.data());
		}
		
		
	}

}
Exemple #2
0
bool equal_dir(const tstring& a, const tchar* b, size_t b_len) {
    TM_ASSERT(b);
    size_t a_len = a.size();
    if (a_len && a[a_len - 1] == path_delim) --a_len;
    if (b_len && b[b_len - 1] == path_delim) --b_len;

    if (b_len != a_len) return false;
    return memcmp(a.data(), b, b_len * sizeof(tchar)) == 0;
}
Exemple #3
0
int lazy_protocol::maybe_have_delim(tstring const& input)
{
    size_t pos =  input.find_first_of(waiter_delim_.data(), waiter_delim_.size());
    if( pos == tstring::npos ) {
        again();
        return 0;
    }
    return call(waiter_method_, tstring(input.data(), pos));
}
Exemple #4
0
std::string basename(tstring const& name)
{
    std::string::size_type p = name.find_last_of("/\\");
    if( p == tstring::npos ) {
        return name.str();
    } else {
        return std::string(name.data()+p+1, name.size()-p-1);
    }
}
Exemple #5
0
int lazy_protocol::maybe_have_enough_bytes(tstring const& input)
{
    if( input.size() < waiter_count_ ) {
        again();
        return 0;
    }
    
    return call(waiter_method_, tstring(input.data(), waiter_count_));
}
Exemple #6
0
tstring FileUtil::GetFileFullPathNameWithCurrentDir(const tstring &filename)
{
	tchar buf[BUF_SIZE] = { _T('\0') };
	tchar **lppPart = NULL;

	DWORD ret = ::GetFullPathName(filename.data(), BUF_SIZE, buf, lppPart);
	if (ret == 0)
		return filename;

	return buf;
}
Exemple #7
0
std::string dirname(tstring const& name)
{
    if( name.size() == 0 ) return ".";
    tstring::size_type p = name.find_last_of("/\\");
    if( p == tstring::npos ) {
        return ".";
    } else if( p == 0 )  {
        return "/";
    } else {
        return std::string(name.data(), p);
    }
}
Exemple #8
0
int tstring::cmp(tstring const& other) const {
    size_t common_length = std::min(size(),other.size()); // WINDOWS min macro workaround
    
    int r = std::memcmp(data(), other.data(), common_length);
    if( r != 0 ) 
        return r;
    if( tstring::size() > other.size() )
        return -1;
    else if( tstring::size() < other.size() )
        return 1;
    else
        return 0;
}
Exemple #9
0
static std::string find_variant(tstring const& filename, std::vector<std::string> const& extensions)
{
    std::string pathext;
    for( std::vector<std::string>::const_iterator iext = extensions.begin(); iext != extensions.end(); ++iext ) {
        pathext.reserve(filename.size() + iext->size());
        
        pathext.assign(filename.data(), filename.size());
        pathext.append(*iext);
        
        if( fs::exists(pathext) ) {
            return pathext;
        }
    }
    return "";
}
Exemple #10
0
void        write_all(output_stream& output, tstring const& data)
{
    using tinfra::fail;
    using tinfra::tsprintf;

    size_t to_write              = data.size();
    size_t buffer_to_write_index = 0;

    while( to_write > 0 ) {
        const int w = output.write(data.data() + buffer_to_write_index, to_write);
        if( to_write != 0 && w == 0 ) {
            fail(tsprintf("unable to save data, %i bytes left", to_write),
                 "write() unexpectedly returned 0");
        }
        to_write -= w;
        buffer_to_write_index += w;
    }
}
Exemple #11
0
static void join_append(std::string& result, tstring component, bool& separator_flag)
{
    if( component.size() > 0 ) {
	const bool start_last_is_separator = result.size() > 0 && (result[result.size()-1] == '/');
	const bool first_char_of_component_is_separator = (component[0] == '/');
	if( start_last_is_separator && first_char_of_component_is_separator ) {
	    // if we already have XXX/ and add /FOO then
	    // just advance one char in added component
	    component = component.substr(1);
	} else if( separator_flag && !first_char_of_component_is_separator ) {
	    // if we need separator and it's not already
	    // in place, add it
	    result.append("/");
	}
        result.append(component.data(), component.size());

	const bool result_last_is_separator = (result[result.size()-1] == '/');
	separator_flag = !result_last_is_separator;
    }
}
Exemple #12
0
bool is_executable(tstring const& name, std::vector<std::string> const& extensions)
{
    // check existence
    if( !tinfra::fs::exists(name) )
        return false;
    
    // check correct extension
    const size_t name_len = name.size();
    for( std::vector<std::string>::const_iterator iext = extensions.begin();
          iext != extensions.end(); ++iext)
    {
        const std::string& ext    = *iext;
        const size_t       extlen = ext.size();
        
        if( name_len < extlen )
            continue;
        
        const tstring actual_ext = name.substr(name_len-extlen, extlen);
        if( compare_no_case(actual_ext.data(), ext.data(), extlen) == 0 ) {
            return true;
        }
    }
    return false;
}
Exemple #13
0
int output_stream::write(tstring const& data)
{
    return this->write(data.data(), data.size());
}
	int RegistryKey::SetStringValue(tchar const *name, tstring &value)
	{
		SXR(RegSetValueEx(mKey, name, 0, REG_SZ, (Byte *)value.data(), (DWORD)value.size()));
		return ERROR_SUCCESS;
	}
Exemple #15
0
void set_srcdir(tstring const& x)
{
    srcdir.assign(x.data(), x.size());
}
Exemple #16
0
	void write_bytes(tstring const& data)
	{
		out_->write(data.data(), data.size());
	}
Exemple #17
0
void lazy_protocol::wait_for_delimiter(tstring const& delim, step_method method)
{
    waiter_delim_.assign(delim.data(), delim.size());
    waiter_method_ = method;
    next(make_step_method(&lazy_protocol::maybe_have_delim));
}
Exemple #18
0
void Script::ParseAttributes(tstring& attributes, Control* control)
{
  INSPECT_SCOPE_TIMER( ("Attributes Script Attribute Processing") );
  
  size_t pos = 0;
  size_t end = tstring::npos;

  while (pos < attributes.length() && pos != tstring::npos)
  {
    // eat ws
    pos = attributes.find_first_not_of(LS_WHITESPACE, pos);

    // the rest is WS, abort
    if (pos == tstring::npos)
      break;

    // search for end of keyword
    end = attributes.find_first_of(LS_WHITESPACE TXT( "=" ), pos);

    // we have no symbol term, just abort
    if (end == tstring::npos)
      break;

    // copy just our symbol into a string
    tstring key (attributes.data() + pos, end - pos);

    // next tchar
    pos = end+1;

    // eat ws
    pos = attributes.find_first_not_of(LS_WHITESPACE, pos);

    // the rest is WS, abort
    if (pos == tstring::npos)
      break;

    // see if the value is directly quoted
    size_t startQuote = attributes.find_first_of( TXT( "\"" ), pos);
    size_t endQuote = attributes.find_first_of( TXT( "\"" ), startQuote+1);

    // search for end of keyword
    end = attributes.find_first_of( TXT( ";" ), pos);

    // if the semi is in the quote
    if (startQuote != tstring::npos && endQuote != tstring::npos && startQuote < end && end < endQuote)
    {
      // search for end of value not quoted
      end = attributes.find_first_of( TXT( ";" ), endQuote);
    }

    // we have no symbol term, just abort
    if (end == tstring::npos)
    {
      end = attributes.length();
    }

    // copy just our symbol into a string
    tstring value (attributes.data() + pos, end - pos);

    // next tchar
    pos = end+1;

    // trim quoted values
    {
      size_t start = value.find_first_of('\"');
      size_t finish = value.find_last_of('\"');

      if (start != tstring::npos)
      {
        if (start == finish)
        {
          value.erase(start, 1);
        }
        else if (start < finish)
        {
          value = value.substr(start + 1, finish - start - 1);
        }
      }
    }

    // insert
    control->Process(key, value);
  }
}
Exemple #19
0
bool equal_file(const tstring& a, const tchar* b, size_t b_len) {
    TM_ASSERT(b);
    if (b_len != a.size()) return false;
    return memcmp(a.data(), b, b_len * sizeof(tchar)) == 0;
}
Exemple #20
0
void set_test_resources_dir(tstring const& x)
{
    top_srcdir.assign(x.data(), x.size());
}