之前写了《 flex 事件之理解》和《 flex meta tag 之理解》,本想是为写本文 flex 数据绑定之理解做铺垫的,谁知网上已有 flex 数据绑定之理解很好的文章,如下:
http://www.cnblogs.com/nianshi/archive/2010/05/19/1739407.html , FLEX 数据绑定 (1)
http://www.cnblogs.com/nianshi/archive/2010/05/19/1739409.html , FLEX 数据绑定 (2)
http://www.cnblogs.com/nianshi/archive/2010/05/19/1739411.html , FLEX 数据绑定 (3)
因此,已无再详片大论 flex 绑定理解之需要,但是鉴于上述 3 篇文章稍显混论,看起来不是那么通俗易懂,为此,我简单的补充了一个 demo ,并且作简单归纳总结。
1、 flex 绑定通常有 3 中实现方式,即 FLEX 数据绑定 (1) 所述的 {} 绑定、 fx : binding 和 as 代码实现 ( BindingUtils , ChangeWatcher );
2、 flex 绑定分单、双向绑定,默认情况下都是单向绑定;
3、 flex 绑定最常见的编写方式就是 [Bin ......
最近项目中要用到一些web xml数据的访问分析,采用msxml
1.msxml是微软提供的,在非开发环境中,需要注册
2.xml文件,一般在第一句有编码方式,一般默认是utf-8,属于一种unicode
3.从网络采集的xml数据,需要使用winnet函数库
4.winnet采集自网络的数据,默认的都是CP_ACP格式的,简单说就是ANSI或UNICODE,UTF8的编码方式是CP_UTF8,这么看xml数据,字符是正常的,但是汉字都是乱码
5.解决utf-8乱码方法:
UNICODE -> ANSI : CT2A or MultiByteToWideChar
ANSI -> UTF8: WideCharToMultiByte
wstring AStringToWString(const string& szSrc, UINT nCodePage)
{
wstring lstrResult;
if (!szSrc.empty())
{
int length = MultiByteToWideChar(nCodePage, 0, szSrc.c_str(), -1, NULL, 0);
wchar_t* lpwszTemp = new wchar_t[length + 1];
......
一、程序真谛
1.程序就是“搬数”
动作:读取——技术——写出(输入——处理——输出)
数据结构决定数据如何组织,搬动起来效率较高
算法语言决定了如何搬效率较高
2.程序就是“写文章”
双可读性:程序员阅读无障碍、计算机阅读无错误
3.程序就是“复制”
建立自己常用工程程序库,将常用算法和程序经过多年总结和归纳,使之具有高可用性和高正确性,在后期工作时可直接“复制”,缓解工作压力
二、定名
1.函数命名原则
1)首字母大写
2)函数名可很长,要表意清晰
3)无参数的函数在括号内使用void
2.变量命名原则
1)以小写的缩写前缀显示说明该变量的类型,如nCount,pBuffer
2)对于不同作用域的变量,如类成员变量和全局变量,必须以显式的m_和g_前缀区分
3)变量名表意要清晰
4)变量在函数使用过程中严禁转义
5)静态数组指针以sz为前缀,不需要后续程序释放
6)动态申 ......
一、程序真谛
1.程序就是“搬数”
动作:读取——技术——写出(输入——处理——输出)
数据结构决定数据如何组织,搬动起来效率较高
算法语言决定了如何搬效率较高
2.程序就是“写文章”
双可读性:程序员阅读无障碍、计算机阅读无错误
3.程序就是“复制”
建立自己常用工程程序库,将常用算法和程序经过多年总结和归纳,使之具有高可用性和高正确性,在后期工作时可直接“复制”,缓解工作压力
二、定名
1.函数命名原则
1)首字母大写
2)函数名可很长,要表意清晰
3)无参数的函数在括号内使用void
2.变量命名原则
1)以小写的缩写前缀显示说明该变量的类型,如nCount,pBuffer
2)对于不同作用域的变量,如类成员变量和全局变量,必须以显式的m_和g_前缀区分
3)变量名表意要清晰
4)变量在函数使用过程中严禁转义
5)静态数组指针以sz为前缀,不需要后续程序释放
6)动态申 ......
这段源码能在linux下运行!!! 能识别小数
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
/*#define NULL 0*/
/* 自定义变量 */
#define sy_if 0
#define sy_then 1
#define sy_else 2
#define sy_while 3
#define sy_begin 4
#define sy_do 5
#define sy_end 6
#define a 7
#define semicolon 8
#define e 9
#define jinghao & ......
int svd(int m,int n,int withu,int withv,double eps,double tol,
double *a, double *q, double *u, double *v, double *vt)
{
int i,j,k,l,l1,iter,retval;
double c,f,g,h,s,x,y,z;
double *e;
e = (double *)calloc(n,sizeof(double));
retval = 0;
/* Copy 'a' to 'u' */
for (i=0;i<m;i++) {
for (j=0;j<n;j++)
u[i*n + j] = a[i*n + j];
}
/* Householder's reduction to bidiagonal form. */
g = x = 0.0;
for (i=0;i<n;i++) {
e[i] = g;
s = 0.0;
l = i+1;
for (j=i;j<m;j++)
s += (u[j*n+i]*u[j*n+i]);
if (s < tol)
g = 0.0;
else {
f = u[i*n+i];
g = (f < 0) ? sqrt(s) : -sqrt(s);
h = f * g - s;
u[i*n+i] = f - g;
for (j=l;j< ......
In C++, how do i go about using setenv to set the display? I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to overwrite any previous value of argument 1 (DISPLAY). You'd be out of luck if xrandr cached the display name though. In that case, you'd have to re-invoke a program from a shell script: the shell script could set the DISPLAY each time before starting your program. That would be less C++ coding
#include <stdlib.h>
#include <stdio.h>
int main(){
char *env1 = getenv("test11");
printf("test11=%s\n", env1); //show current env variable
setenv("test11","abcd",1); //reset it
env1 = getenv("test11");
printf("test11=%s\n", env1);
//this value reset is gone after the program finished
return 0;
}
g++ setenv.cpp -o mysetenv ......
In C++, how do i go about using setenv to set the display? I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to overwrite any previous value of argument 1 (DISPLAY). You'd be out of luck if xrandr cached the display name though. In that case, you'd have to re-invoke a program from a shell script: the shell script could set the DISPLAY each time before starting your program. That would be less C++ coding
#include <stdlib.h>
#include <stdio.h>
int main(){
char *env1 = getenv("test11");
printf("test11=%s\n", env1); //show current env variable
setenv("test11","abcd",1); //reset it
env1 = getenv("test11");
printf("test11=%s\n", env1);
//this value reset is gone after the program finished
return 0;
}
g++ setenv.cpp -o mysetenv ......