Questions in category: UPP (UPP)
软件 >> C++ >> UPP

1. [TheIDE] 在工程 Calculator 中添加某一目录下的文件.

Posted by haifeng on 2023-06-27 17:43:38 last update 2023-06-27 18:23:05 | Answers (0) | 收藏


在左下角点击右键, insert special-->Import directory tree into package

 

由于使用了 std::string_view, 所以编译前更改一些选项. 如果是 VS2019, 则在 C/C++ --> 语言, C++语言标准中选择 ISO C++17标准(/std:c++17)

 

如果使用的是 U++,

在 Build methods 中, Builder: MSC19

Common C++ options:  /std:c++17

2. UPP 中获取系统变量的一些函数

Posted by haifeng on 2023-01-14 14:44:53 last update 2023-01-14 14:44:53 | Answers (0) | 收藏


Cout() << "Home directory: " << GetHomeDirectory() <<"\n";
Cout() << "Programs Folder: " << GetProgramsFolder() <<"\n";
Cout() << "Programs Folder(X86): " << GetProgramsFolderX86() <<"\n";
Cout() << "Temp directory: " << GetTempDirectory() <<"\n";

 

更改目录

ChangeCurrentDirectory("D:\\bin"); 

 

References:

U++ forum: Welcome to the forum (ultimatepp.org)

 

3. [UPP] help 中的 .tpp 文件如何转换成 .tppi 文件?

Posted by haifeng on 2022-08-21 07:59:25 last update 2022-08-21 07:59:25 | Answers (0) | 收藏


 

例如文件 main_en-us.tppi 的内容如下

TITLE("This is Topic++ example page")
COMPRESSED
120,156,139,86,80,81,49,208,49,80,54,32,0,172,92,82,211,18,75,115,74,98,163,171,227,107,85,93,253,116,67,131,21,162,139,13,172,109,21,162,181,204,20,66,50,50,139,21,128,40,36,191,32,51,57,65,59,65,91,33,181,34,49,183,32,39,85,161,32,49,61,53,86,45,22,164,84,1,74,193,20,39,42,68,199,149,128,53,88,37,232,39,232,67,244,234,39,22,20,36,232,131,116,25,37,168,164,230,37,232,150,22,199,41,228,100,230,101,43,148,228,43,36,230,229,151,100,164,22,65,12,213,131,26,23,27,11,0,207,59,59,34,

 

这里 COMPRESSED 部分的内容是如何获得的?

4. U++ 中涉及字符串的函数

Posted by haifeng on 2021-06-17 22:51:22 last update 2021-06-17 22:52:26 | Answers (0) | 收藏


tmpstr 存储了文件名, 现在检查其是否以 ".mp3" 结尾, 可以使用 EndsWith() 函数

if(tmpstr.Find(strToFind)+4==tmpstr.GetLength())
if(tmpstr.EndsWith(".mp3"))

与之对应, 检查tmpstr是否以某字符串作为开头, 可以使用 StartWith()函数.

GetLength() 与 GetCount() 是同义的, 计算其中含有字符的个数.  类似于 std::string 中的 size() 或 length() 函数.

 


References:

U++ Core Tutorial :: Ultimate++ (ultimatepp.org)

 

5. U++中的主函数

Posted by haifeng on 2021-04-11 15:36:19 last update 2021-04-11 15:36:19 | Answers (0) | 收藏


U++中的main函数形如

GUI_APP_MAIN
{
App::App().Run();
}
 
事实上, 这里 GUI_APP_MAIN 是一个宏, 定义在 U++Framework/upp/uppsrc/CtrlCore/CtrlCore.defs 中. 内容为:

#define GUI_APP_MAIN  void GUI_APP_MAIN()

6. Upp 的 core.h 中重复加载 math.h

Posted by haifeng on 2021-04-11 10:12:06 last update 2021-04-11 10:12:06 | Answers (0) | 收藏


#ifndef CORE_H
#define CORE_H
 
#define UPP_VERSION 0x20200200
 
#ifndef flagMT
#define flagMT // MT is now always on
#endif
 
#define _MULTITHREADED
#define MULTITHREADED
#ifdef flagDLL
#define flagUSEMALLOC
#define STD_NEWDELETE
#endif
 
#ifdef flagDLL
#define _USRDLL
#endif
 
#ifdef flagHEAPDBG
#define HEAPDBG
#endif
 
#if defined(flagDEBUG)
#ifndef _DEBUG
#define _DEBUG
#endif
#ifndef TESTLEAKS
#define TESTLEAKS
#endif
#ifndef HEAPDBG
#define HEAPDBG
#endif
#else
#ifndef _RELEASE
#define _RELEASE
#endif
#endif
 
#include "config.h"
 
#if defined(flagSTD_NEWDELETE) && !defined(STD_NEWDELETE)
#define STD_NEWDELETE
#endif
 
#ifdef _MSC_VER
#ifndef _CPPRTTI
#error  RTTI must be enabled !!!
#endif  //_CPPRTTI
#endif
 
#include <typeinfo>
#include <stddef.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <ctype.h>
 
#ifdef CPU_X86
#include <immintrin.h>
#endif
 
#if defined(PLATFORM_POSIX)
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#define DIR_SEP  '/'
#define DIR_SEPS "/"
#define PLATFORM_PATH_HAS_CASE 1
 
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/file.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <memory.h>
#include <dirent.h>
#include <signal.h>
#include <syslog.h>
#include <float.h>
#include <fenv.h>
#ifdef PLATFORM_SOLARIS
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#ifdef PLATFORM_OSX
#include <dispatch/dispatch.h>
#endif
#endif //PLATFORM_POSIX
 
#ifdef PLATFORM_POSIX
#define LOFF_T_      off_t
#define LSEEK64_     lseek
#define FTRUNCATE64_ ftruncate
#endif
 
#ifdef PLATFORM_LINUX
#undef  LOFF_T_
#define LOFF_T_      loff_t
#undef  LSEEK64_
#define LSEEK64_     lseek64
#undef  FTRUNCATE64_
#define FTRUNCATE64_ ftruncate64
#endif
 
#ifdef PLATFORM_WIN32
 
#if defined(COMPILER_MSC) && defined(CPU_X86)
#pragma warning(disable: 4035)
#else
#ifndef __NOASSEMBLY__
#define __NOASSEMBLY__
#endif
#endif
 
#if defined(COMPILER_MINGW)
#if !defined(WINVER)
#define WINVER 0xFFFF
#endif
#include <float.h>
#endif
 
#define DIR_SEP  '\\'
#define DIR_SEPS "\\"
#define PLATFORM_PATH_HAS_CASE 0
#ifndef PLATFORM_WINCE
#include <io.h>
#endif
#ifndef PLATFORM_MFC // just mini Windows headers
#ifdef COMPILER_MSC
#ifndef CPU_ARM
#ifndef CPU_AMD64
#ifndef _X86_
#define _X86_
#endif
#else
#ifndef _AMD64_
#define _AMD64_
#endif
#ifndef __NOASSEMBLY__
#define __NOASSEMBLY__
#endif
#ifndef WIN64
#define WIN64
#endif
#endif
#endif
#ifndef _WINDOWS_
#define _WINDOWS_
#endif
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#endif
#ifndef _STRUCT_NAME
#define _STRUCT_NAME(x)
#define DUMMYSTRUCTNAME
#define DUMMYSTRUCTNAME2
#define DUMMYSTRUCTNAME3
#endif
#ifndef NO_STRICT
#ifndef STRICT
#define STRICT 1
#endif
#endif
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <Wincon.h>
#include <float.h>
#include <mmsystem.h>
#define byte win32_byte_ // RpcNdr defines byte -> class with Upp::byte
#define CY win32_CY_
#include <objidl.h>
#include <winnetwk.h>
#undef byte
#undef CY
typedef DWORD LCTYPE;
#define W_P(w, p) w
#include <winsock2.h>
#include <ws2tcpip.h>
typedef int socklen_t;
#else
#define W_P(w, p) w
#if !defined(PLATFORM_CYGWIN)
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
typedef int socklen_t;
#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */
#include <windows.h>
#include <stdint.h>
#endif
#include <process.h>
#endif
 
#ifdef RGBA
#undef RGBA
#endif
#endif
 
#ifdef PLATFORM_POSIX
 
#define W_P(w, p) p
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
//#include <libiberty.h>
enum
{
INVALID_SOCKET = -1,
TCP_NODELAY    = 1,
SD_RECEIVE     = 0,
SD_SEND        = 1,
SD_BOTH        = 2,
};
typedef int SOCKET;
#endif
 
#ifdef PLATFORM_WIN32
#include <plugin/z/lib/zlib.h>
#else
#include <zlib.h>
#endif
 
#include <functional>
#include <algorithm>
#include <string>
#include <complex>
#include <type_traits>
#include <atomic>
#include <chrono>
#include <utility>
 
// fix MSC8 beta problem....
#ifdef COMPILER_MSC
#ifndef PLATFORM_WINCE
namespace std {
inline void __cdecl _Debug_message(const wchar_t *, const wchar_t *, unsigned int line) {}
};
#endif
#endif
 
// deprecated, use 'namespace' directly instead of macros
#define NAMESPACE_UPP     namespace Upp {
#define END_UPP_NAMESPACE }
#define UPP               Upp
 
// #define atof @ // atof is broken, as it depends on setlocale - might want ',' instead of '.' breaking a lot of code
// Use Atof instead (which accepts both '.' and ',' as decimal separator)
 
namespace Upp {
 
#ifndef flagNODEPRECATED
#define DEPRECATED
#endif
 
#include "Defs.h"
 
class XmlIO;
class JsonIO;
 
#include "Ops.h"
#include "Fn.h"
 
#ifdef flagNOSIMD
#ifdef CPU_SSE2
#undef CPU_SSE2
#endif
#ifdef CPU_NEON
#undef CPU_NEON
#endif
#endif
 
#if defined(CPU_SSE2) && defined(CPU_32) && defined(PLATFORM_POSIX)
#undef CPU_SSE2
#endif
 
#ifdef CPU_SSE2
#include "SIMD_SSE2.h"
#define CPU_SIMD 1
#endif
 
#ifdef CPU_NEON
#include "SIMD_NEON.h"
#define CPU_SIMD 1
#endif
 
#include "Mem.h"
#include "Atomic.h"
#include "Topt.h"
#include "Mt.h"
#include "String.h"
 
#include "TimeDate.h"
#include "Path.h"
#include "Stream.h"
#include "Diag.h"
 
#include "Vcont.h"
#include "Range.h"
#include "BiCont.h"
#include "Index.h"
#include "Map.h"
#include "Algo.h"
#include "Sorted.h"
#include "Sort.h"
#include "Obsolete.h"
#include "FixedMap.h"
#include "InVector.h"
 
#include "CharSet.h"
 
#include "SplitMerge.h"
 
#include "Other.h"
 
#include "Lang.h"
 
#include "Value.h"
#include "ValueUtil.h"
 
#include "Tuple.h"
 
#include "Uuid.h"
#include "Ptr.h"
 
#include "Function.h"
 
#include "Callback.h"
 
#include "Color.h"
#include "Complex.h"
 
#include "Hash.h"
 
#include "Util.h"
 
#include "Profile.h"
 
#include "FilterStream.h"
 
#include "Format.h"
#include "Convert.h"
 
#include "z.h"
 
#include "Parser.h"
#include "JSON.h"
#include "XML.h"
#include "Xmlize.h"
 
#include "Gtypes.h"
#include "i18n.h"
#include "Topic.h"
 
#include "App.h"
 
#include "CoWork.h"
 
#include "CoAlgo.h"
#include "CoSort.h"
 
#include "LocalProcess.h"
 
#include "Inet.h"
 
#include "Win32Util.h"
 
#include "Vcont.hpp"
#include "Index.hpp"
#include "Map.hpp"
#include "InVector.hpp"
#include "InMap.hpp"
 
#include "Huge.h"
 
#include "ValueCache.h"
 
#ifdef CPU_SIMD
String AsString(const f32x4& x);
String AsString(const i32x4& x);
String AsString(const i16x8& x);
String AsString(const i8x16& x);
#endif
 
#ifdef PLATFORM_WIN32
NTL_MOVEABLE(POINT)
NTL_MOVEABLE(SIZE)
NTL_MOVEABLE(RECT)
#endif
 
}
 
#if (defined(TESTLEAKS) || defined(HEAPDBG)) && defined(COMPILER_GCC) && defined(UPP_HEAP)
 
//Place it to the begining of each file to be the first function called in whole executable...
//This is now backup to init_priority attribute in heapdbg.cpp
//$-
struct MemDiagCls {
MemDiagCls();
~MemDiagCls();
};
static const MemDiagCls sMemDiagHelper__upp__;
//$+
 
 
#endif
 
//some global definitions
 
void      RegisterTopic__(const char *topicfile, const char *topic, const char *title, const UPP::byte *data, int len);
 
#ifdef PLATFORM_WIN32
typedef HMODULE DLLHANDLE;
#else
typedef void   *DLLHANDLE;
#endif
 
DLLHANDLE LoadDll__(UPP::String& fn, const char *const *names, void *const *procs);
void      FreeDll__(DLLHANDLE dllhandle);
 
#ifndef flagNONAMESPACE
using Upp::byte; // Dirty solution to Windows.h typedef byte...
#endif
 
#endif //CORE_H

7. Upp 中的一些函数简介

Posted by haifeng on 2021-04-11 09:18:51 last update 2021-04-11 10:21:59 | Answers (0) | 收藏


Sizeable().Zoomable();//Sizeable()使得应用程序界面可以调整大小, Zoomable()使得应用程序界面可以放大缩小.

 

Splitter.h 中定义的类 Splitter 继承自 Ctrl 类. 

class Splitter : public Ctrl {

}

 

Splitter.h 位于 U++Framework/upp/uppsrc/CtrlLib 目录.

而 Ctrl 类的声明见 U++Framework/upp/uppsrc/CtrlCore/CtrlCore.h

Ctrl 类的具体实现见 U++Framework/upp/uppsrc/CtrlCore/Ctrl.cpp